davidmoreno / onion

C library to create simple HTTP servers and Web Applications.
http://www.coralbits.com/libonion/
Other
2.01k stars 251 forks source link

random-default.c: Don't exit if we read less bytes from /dev/random #294

Closed pcarranzav2 closed 3 years ago

pcarranzav2 commented 3 years ago

Hi! First time contributing here so please let me know if there's anything else needed for the PR.

Reading from /dev/random might return less than the expected amount of bytes, and that should be okay. We can just keep reading until we have enough bytes.

(imo it'd probably be better to use /dev/urandom here and we could even read from /dev/urandom on each call to onion_random_generate, but this change should avoid making the program exit without changing the random implementation too much)

davidmoreno commented 3 years ago

Thanks!

It's only for the seed value, so its highly unlikely we are out of randomness.. but its more complete now.