From e55e4687543793216b501e0de8fd3fbeb4264e1b Mon Sep 17 00:00:00 2001
From: Matt Johnston <matt@ucc.asn.au>
Date: Tue, 2 Apr 2013 18:53:18 +0800
Subject: [PATCH] Fix segfault when /dev/urandom isn't writable

---
 random.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/random.c b/random.c
index 0378e9a6..f935e215 100644
--- a/random.c
+++ b/random.c
@@ -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);
-- 
GitLab