Make get_ip() a bit more strict in it's parsing of IP addresses, and
authorRichard Levitte <levitte@openssl.org>
Mon, 25 Jun 2001 14:12:45 +0000 (14:12 +0000)
committerRichard Levitte <levitte@openssl.org>
Mon, 25 Jun 2001 14:12:45 +0000 (14:12 +0000)
at the same time a bit more accepting with host names.

crypto/bio/b_sock.c

index d4b44b62bbaac55f55c488eb6ba16dd6e78229ba..5b66603d7d92a5982908dbde542d7042d737fe76 100644 (file)
@@ -494,16 +494,16 @@ static int get_ip(const char *str, unsigned char ip[4])
                        {
                        ok=1;
                        tmp[num]=tmp[num]*10+c-'0';
-                       if (tmp[num] > 255) return(-1);
+                       if (tmp[num] > 255) return(0);
                        }
                else if (c == '.')
                        {
                        if (!ok) return(-1);
-                       if (num == 3) break;
+                       if (num == 3) return(0);
                        num++;
                        ok=0;
                        }
-               else if ((num == 3) && ok)
+               else if (c == '\0' && (num == 3) && ok)
                        break;
                else
                        return(0);