Skip to content

Fixed infinite block on /dev/urandom#24

Open
NickCody wants to merge 1 commit intocu-ecen-aeld:masterfrom
NickCody:master
Open

Fixed infinite block on /dev/urandom#24
NickCody wants to merge 1 commit intocu-ecen-aeld:masterfrom
NickCody:master

Conversation

@NickCody
Copy link
Copy Markdown

cat on /dev/urandom will never finish, as far as I know. This code will use dd to "read" 30 bytes only, which will finish so the temp filename can be generated.

This code is blocking github actions, which is blocking my submission.

I'm running Ubuntu 20.04.5 LTS.

@dwalkes
Copy link
Copy Markdown
Contributor

dwalkes commented Aug 30, 2024

Interesting, thanks for reporting and sorry for the slow response, I didn't have notifications setup correctly for this repo.

Regarding:

cat on /dev/urandom will never finish, as far as I know.

I think that's a correct statement, however the combination of fold -w32 | head -n 1 should mean the command exits after the first 32 characters which were in the set 'a-zA-Z0-9' were generated. So I suspect some issue with your random number generator which means it isn't returning any characters in this set or isn't returning enough characters in this set for some reason. I can't reproduce and I'm not aware of anyone else reproducing.

I think your proposed change would fail if you got no characters in the set 'a-zA-Z0-9' within the first 30 bytes obtained from urandom, so that is probably not the best approach either.

I think it should be possible to use mktemp here instead and this might be the safest change to make.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants