X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=crypto%2Frand%2Frand_egd.c;h=3c69fd2169dbb0fb5fed26e2d4440bd6710ea918;hp=d7dad3efd02c239e37ed520d6e39938618b86051;hb=6977c7e2baf291278aee7632f1a68581b7c4d1f9;hpb=6a89a25c27df0677e78567cd02c77f30e80814af diff --git a/crypto/rand/rand_egd.c b/crypto/rand/rand_egd.c index d7dad3efd0..3c69fd2169 100644 --- a/crypto/rand/rand_egd.c +++ b/crypto/rand/rand_egd.c @@ -56,8 +56,9 @@ #include #include +#include -/* +/*- * Query the EGD . * * This module supplies three routines: @@ -94,7 +95,7 @@ * RAND_egd() is a wrapper for RAND_egd_bytes() with numbytes=255. */ -#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_MSDOS) +#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_NETWARE) || defined(OPENSSL_SYS_VOS) || defined(OPENSSL_SYS_BEOS) int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes) { return(-1); @@ -143,9 +144,9 @@ int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes) memset(&addr, 0, sizeof(addr)); addr.sun_family = AF_UNIX; - if (strlen(path) > sizeof(addr.sun_path)) + if (strlen(path) >= sizeof(addr.sun_path)) return (-1); - strcpy(addr.sun_path,path); + BUF_strlcpy(addr.sun_path,path,sizeof addr.sun_path); len = offsetof(struct sockaddr_un, sun_path) + strlen(path); fd = socket(AF_UNIX, SOCK_STREAM, 0); if (fd == -1) return (-1); @@ -215,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 { @@ -245,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 {