Don't forget that strlen() doesn't include the ending NUL.
authorRichard Levitte <levitte@openssl.org>
Wed, 21 May 2003 14:41:02 +0000 (14:41 +0000)
committerRichard Levitte <levitte@openssl.org>
Wed, 21 May 2003 14:41:02 +0000 (14:41 +0000)
PR: 618

crypto/rand/rand_egd.c

index ce169367857a5c38a52eb6db86da2ea31845f533..62229d97dae366ecd8f2a1067972225e416ecaeb 100644 (file)
@@ -102,7 +102,7 @@ int RAND_egd(const char *path)
 
        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);
        len = offsetof(struct sockaddr_un, sun_path) + strlen(path);
@@ -134,7 +134,7 @@ int RAND_egd_bytes(const char *path,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);
        len = offsetof(struct sockaddr_un, sun_path) + strlen(path);