Skip to content

Fix incorrect declaration of randombytes() in tweetnacl.c#3

Open
alexisrozhkov wants to merge 1 commit intoultramancool:masterfrom
alexisrozhkov:master
Open

Fix incorrect declaration of randombytes() in tweetnacl.c#3
alexisrozhkov wants to merge 1 commit intoultramancool:masterfrom
alexisrozhkov:master

Conversation

@alexisrozhkov
Copy link
Copy Markdown

Declaring randombytes() with incorrect signature (u64 for length in declaration vs unsigned int in definition) leads to incorrect type casting on some platforms (armeabi-v7a for instance, probably other 32-bit platforms as well), and as a result fread() from /dev/urandom might (depends on casting result) fail trying to read more than 0x7ffff000 bytes (see notes section here).

Also it might make more sense to swap 2nd and 3rd arguments to fread (size and nmemb) and check for the number of read elements. Current implementation should also work, so it's left as is.

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.

1 participant