diff random.c @ 735:73b6e5d8801b

Fix segfault when /dev/urandom isn't writable
author Matt Johnston <matt@ucc.asn.au>
date Tue, 02 Apr 2013 18:53:18 +0800
parents 84157e435c52
children 7deb6fda1319
line wrap: on
line diff
--- a/random.c	Mon Apr 01 22:26:55 2013 +0800
+++ b/random.c	Tue Apr 02 18:53:18 2013 +0800
@@ -157,6 +157,9 @@
 	/* 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);