From 8fe534a51df4ff1faf1737e5cbaf3cbc6dc0f746 Mon Sep 17 00:00:00 2001 From: Pavel Charvat Date: Tue, 25 Apr 2006 09:54:00 +0200 Subject: [PATCH] - fixed accepted double 0x prefix ("0x0x12345678") and negative numbers ("-0.-0.-0.-0") in IP parser --- lib/conf2.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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) -- 2.39.2