From: havoc Date: Thu, 18 Jan 2007 08:49:50 +0000 (+0000) Subject: support partial IP addresses in the ipv4 address parser, this fixes the 20+ second... X-Git-Tag: xonotic-v0.1.0preview~3707 X-Git-Url: https://git.xonotic.org/?a=commitdiff_plain;h=f4d2a29a1fc44ff088c99b70c66e6749c8c24683;p=xonotic%2Fdarkplaces.git support partial IP addresses in the ipv4 address parser, this fixes the 20+ second delay when parsing status messages on some modified quake servers that report only partial addresses (hiding the last octet) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6697 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/lhnet.c b/lhnet.c index 4099ac68..4f820099 100644 --- 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;