From: Pavel Charvat Date: Tue, 25 Apr 2006 07:54:00 +0000 (+0200) Subject: - fixed accepted double 0x prefix ("0x0x12345678") and X-Git-Tag: holmes-import~645^2~11^2~47 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=8fe534a51df4ff1faf1737e5cbaf3cbc6dc0f746;p=libucw.git - fixed accepted double 0x prefix ("0x0x12345678") and negative numbers ("-0.-0.-0.-0") in IP parser --- diff --git a/lib/conf2.c b/lib/conf2.c index 900e8e55..7216becd 100644 --- a/lib/conf2.c +++ b/lib/conf2.c @@ -555,10 +555,10 @@ cf_parse_ip(byte *p, u32 *varp) return "Missing IP address"; uns x = 0; char *p2; - if (*p == '0' && p[1] | 32 == 'X') { + if (*p == '0' && p[1] | 32 == 'X' && Cxdigit(p[2])) { errno = 0; - x = strtoul(p + 2, &p2, 16); - if (errno == ERANGE || p2 == (char*) (p+2) || x > 0xffffffff) + x = strtoul(p, &p2, 16); + if (errno == ERANGE || x > 0xffffffff) goto error; p = p2; } @@ -568,6 +568,8 @@ cf_parse_ip(byte *p, u32 *varp) if (*p++ != '.') goto error; } + if (!Cdigit(*p)) + goto error; errno = 0; uns y = strtoul(p, &p2, 10); if (errno == ERANGE || p2 == (char*) p || y > 255)