]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
support partial IP addresses in the ipv4 address parser, this fixes the 20+ second...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 18 Jan 2007 08:49:50 +0000 (08:49 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 18 Jan 2007 08:49:50 +0000 (08:49 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6697 d7cf8633-e32d-0410-b094-e92efae38249

lhnet.c

diff --git a/lhnet.c b/lhnet.c
index 4099ac6809e74a9690b91fd2fe268d687ecb3f2d..4f820099e2e6e2efe3e6707a359fa6ea064d9552 100644 (file)
--- a/lhnet.c
+++ b/lhnet.c
@@ -134,7 +134,9 @@ int LHNETADDRESS_FromString(lhnetaddress_t *address, const char *string, int def
                return 1;
        }
        // try to parse as dotted decimal ipv4 address first
-       if (sscanf(name, "%d.%d.%d.%d", &d1, &d2, &d3, &d4) == 4 && (unsigned int)d1 < 256 && (unsigned int)d2 < 256 && (unsigned int)d3 < 256 && (unsigned int)d4 < 256)
+       // note this supports partial ip addresses
+       d1 = d2 = d3 = d4 = 0;
+       if (sscanf(name, "%d.%d.%d.%d", &d1, &d2, &d3, &d4) >= 1 && (unsigned int)d1 < 256 && (unsigned int)d2 < 256 && (unsigned int)d3 < 256 && (unsigned int)d4 < 256)
        {
                // parsed a valid ipv4 address
                address->addresstype = LHNETADDRESSTYPE_INET4;