From: Miroslav Lichvar Date: Mon, 18 May 2015 13:36:52 +0000 (+0200) Subject: client: handle empty hostname before slash in allow/deny commands X-Git-Tag: 2.1-pre1~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2c35f56612b01583b7434683814c2eb76ceb522c;p=thirdparty%2Fchrony.git client: handle empty hostname before slash in allow/deny commands --- diff --git a/client.c b/client.c index 64eefb74..07161fb1 100644 --- a/client.c +++ b/client.c @@ -640,7 +640,8 @@ process_cmd_manual(CMD_Request *msg, const char *line) static int parse_allow_deny(CMD_Request *msg, char *line) { - unsigned long a, b, c, d, n; + unsigned long a, b, c, d; + int n, specified_subnet_bits; IPAddr ip; char *p; @@ -657,7 +658,7 @@ parse_allow_deny(CMD_Request *msg, char *line) n = 0; if (!UTI_StringToIP(p, &ip) && - (n = sscanf(p, "%lu.%lu.%lu.%lu", &a, &b, &c, &d)) == 0) { + (n = sscanf(p, "%lu.%lu.%lu.%lu", &a, &b, &c, &d)) <= 0) { /* Try to parse as the name of a machine */ if (DNS_Name2IPAddress(p, &ip, 1) != DNS_Success) { @@ -710,7 +711,6 @@ parse_allow_deny(CMD_Request *msg, char *line) UTI_IPHostToNetwork(&ip, &msg->data.allow_deny.ip); if (slashpos) { - int specified_subnet_bits, n; n = sscanf(slashpos+1, "%d", &specified_subnet_bits); if (n == 1) { msg->data.allow_deny.subnet_bits = htonl(specified_subnet_bits);