1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-10 09:58:01 +00:00

get_random_data() can return NULL (for instance, if we can't open /dev/random

on Unix), yet cmdgen failed to deal with this. Spotted by Darren Tucker.

[originally from svn r7396]
This commit is contained in:
Jacob Nevins 2007-03-13 14:43:14 +00:00
parent 2b0d1b0224
commit 36db0d6f72

View File

@ -640,6 +640,11 @@ int main(int argc, char **argv)
random_ref(); random_ref();
entropy = get_random_data(bits / 8); entropy = get_random_data(bits / 8);
if (!entropy) {
fprintf(stderr, "puttygen: failed to collect entropy, "
"could not generate key\n");
return 1;
}
random_add_heavynoise(entropy, bits / 8); random_add_heavynoise(entropy, bits / 8);
memset(entropy, 0, bits/8); memset(entropy, 0, bits/8);
sfree(entropy); sfree(entropy);