Mercurial > dropbear
comparison 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 |
comparison
equal
deleted
inserted
replaced
733:70811267715c | 735:73b6e5d8801b |
---|---|
155 { | 155 { |
156 #ifndef DROPBEAR_PRNGD_SOCKET | 156 #ifndef DROPBEAR_PRNGD_SOCKET |
157 /* This is opportunistic, don't worry about failure */ | 157 /* This is opportunistic, don't worry about failure */ |
158 unsigned char buf[INIT_SEED_SIZE]; | 158 unsigned char buf[INIT_SEED_SIZE]; |
159 FILE *f = fopen(DROPBEAR_URANDOM_DEV, "w"); | 159 FILE *f = fopen(DROPBEAR_URANDOM_DEV, "w"); |
160 if (!f) { | |
161 return; | |
162 } | |
160 genrandom(buf, sizeof(buf)); | 163 genrandom(buf, sizeof(buf)); |
161 fwrite(buf, sizeof(buf), 1, f); | 164 fwrite(buf, sizeof(buf), 1, f); |
162 fclose(f); | 165 fclose(f); |
163 #endif | 166 #endif |
164 } | 167 } |