diff options
author | Matt Johnston <matt@ucc.asn.au> | 2013-04-02 18:53:18 +0800 |
---|---|---|
committer | Matt Johnston <matt@ucc.asn.au> | 2013-04-02 18:53:18 +0800 |
commit | e55e4687543793216b501e0de8fd3fbeb4264e1b (patch) | |
tree | d792868ec2f7d93ca698121d7ff254f2c79dcfe8 | |
parent | 90b5691183f12d348d2651e026e8438ad278c2be (diff) |
Fix segfault when /dev/urandom isn't writable
-rw-r--r-- | random.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -157,6 +157,9 @@ static void write_urandom() /* This is opportunistic, don't worry about failure */ unsigned char buf[INIT_SEED_SIZE]; FILE *f = fopen(DROPBEAR_URANDOM_DEV, "w"); + if (!f) { + return; + } genrandom(buf, sizeof(buf)); fwrite(buf, sizeof(buf), 1, f); fclose(f); |