From f69a8aebab14a24181ea9ce91d52278edce7e7b7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lutz=20J=C3=A4nicke?= Date: Sat, 19 Feb 2005 10:19:07 +0000 Subject: [PATCH] Fix hang in EGD/PRNGD query when communication socket is closed prematurely by EGD/PRNGD. PR: 1014 Submitted by: Darren Tucker --- CHANGES | 4 ++++ crypto/rand/rand_egd.c | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 28b0e29514..4d766fb2f2 100644 --- a/CHANGES +++ b/CHANGES @@ -750,6 +750,10 @@ Changes between 0.9.7e and 0.9.7f [XX xxx XXXX] + *) Fix hang in EGD/PRNGD query when communication socket is closed + prematurely by EGD/PRNGD. + [Darren Tucker via Lutz Jänicke, resolves #1014] + *) Prompt for pass phrases when appropriate for PKCS12 input format. [Steve Henson] 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 { -- 2.25.1