Commit ecd5c4bc authored by Yalu Zhang's avatar Yalu Zhang
Browse files

Fix a bug in classcfg which misinterprets format of "ipaddr/netmask"

The bug occurred both for IPv4 and IPv6 addresses when netmask is a number, e.g. 24.
parent 7bd2fbdd
Pipeline #127 failed with stages
......@@ -437,8 +437,13 @@ void classcfg_parse_ipaddr_ipmask( const char *optstring, const char* optarg, cl
ipaddr_conv(subStr[0], &ipaddr);
inet_ntop(AF_INET, &(ipaddr), pxipmatch->ipaddr, INET_ADDRSTRLEN);
if(nSubCnt == 2) {
ipmask_conv(subStr[1], &mask);
inet_ntop(AF_INET, &(mask), pxipmatch->mask, INET_ADDRSTRLEN);
if (strchr(subStr[1], '.') != NULL) {
ipmask_conv(subStr[1], &mask);
inet_ntop(AF_INET, &(mask), pxipmatch->mask, INET_ADDRSTRLEN);
} else {
strncpy_s(pxipmatch->mask, sizeof(pxipmatch->mask),
subStr[1], strnlen_s(subStr[1], QCLI_MAX_STR));
}
}
break;
......@@ -446,8 +451,13 @@ void classcfg_parse_ipaddr_ipmask( const char *optstring, const char* optarg, cl
ip6addr_conv(subStr[0], &ipaddr6);
inet_ntop(AF_INET6, &(ipaddr6), pxipmatch->ipaddr, INET_ADDRSTRLEN);
if(nSubCnt == 2) {
ip6mask_conv(subStr[1], &mask6);
inet_ntop(AF_INET6, &(mask6), pxipmatch->mask, INET_ADDRSTRLEN);
if (strchr(subStr[1], ':') != NULL) {
ip6mask_conv(subStr[1], &mask6);
inet_ntop(AF_INET6, &(mask6), pxipmatch->mask, INET_ADDRSTRLEN);
} else {
strncpy_s(pxipmatch->mask, sizeof(pxipmatch->mask),
subStr[1], strnlen_s(subStr[1], QCLI_MAX_STR));
}
}
break;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment