diff options
author | Lutz Jänicke <jaenicke@openssl.org> | 2005-02-19 10:19:07 +0000 |
---|---|---|
committer | Lutz Jänicke <jaenicke@openssl.org> | 2005-02-19 10:19:07 +0000 |
commit | f69a8aebab14a24181ea9ce91d52278edce7e7b7 (patch) | |
tree | 842ed9b88db317f3c2b6daca91e87d60e7b296a1 /crypto | |
parent | 9d10b15ef981239b8a184538131293b3379c2757 (diff) |
Fix hang in EGD/PRNGD query when communication socket is closed
prematurely by EGD/PRNGD.
PR: 1014
Submitted by: Darren Tucker <dtucker@zip.com.au>
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/rand/rand_egd.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/crypto/rand/rand_egd.c b/crypto/rand/rand_egd.c index e34f07c5e8..50bce6caba 100644 --- a/crypto/rand/rand_egd.c +++ b/crypto/rand/rand_egd.c @@ -216,7 +216,9 @@ int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes) while (numbytes != 1) { num = read(fd, egdbuf, 1); - if (num >= 0) + if (num == 0) + goto err; /* descriptor closed */ + else if (num > 0) numbytes += num; else { @@ -246,7 +248,9 @@ int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes) while (numbytes != egdbuf[0]) { num = read(fd, retrievebuf + numbytes, egdbuf[0] - numbytes); - if (num >= 0) + if (num == 0) + goto err; /* descriptor closed */ + else if (num > 0) numbytes += num; else { |