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>
This commit is contained in:
Lutz Jänicke
2005-02-19 10:19:07 +00:00
parent 9d10b15ef9
commit f69a8aebab
2 changed files with 10 additions and 2 deletions

View File

@@ -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
{