Fix segfault when /dev/urandom isn't writable

This commit is contained in:
Matt Johnston 2013-04-02 18:53:18 +08:00
parent 90b5691183
commit e55e468754

View File

@ -157,6 +157,9 @@ static void write_urandom()
/* This is opportunistic, don't worry about failure */ /* This is opportunistic, don't worry about failure */
unsigned char buf[INIT_SEED_SIZE]; unsigned char buf[INIT_SEED_SIZE];
FILE *f = fopen(DROPBEAR_URANDOM_DEV, "w"); FILE *f = fopen(DROPBEAR_URANDOM_DEV, "w");
if (!f) {
return;
}
genrandom(buf, sizeof(buf)); genrandom(buf, sizeof(buf));
fwrite(buf, sizeof(buf), 1, f); fwrite(buf, sizeof(buf), 1, f);
fclose(f); fclose(f);