tcpd/tcp_wrappers_7.6-ipv6.fix.fix.diff

31 lines
899 B
Diff

--- hosts_access.c.orig
+++ hosts_access.c
@@ -354,7 +354,26 @@ char *string;
/* If prefix was given, handle it */
if ((mask = split_at(token, '/')) != 0)
{
- if (sscanf(mask, "%d", &prefixlen) != 1 || prefixlen < 0)
+ if (strchr(mask, '.') != NULL) /* We have something
+ like 255.255.0.0 */
+ {
+ int b1, b2, b3, b4;
+ uint32_t netmask;
+
+ if (sscanf(mask, "%d.%d.%d.%d", &b1, &b2, &b3, &b4) != 4)
+ {
+ tcpd_warn ("Wrong netmask in %s", tok);
+ return (NO);
+ }
+ netmask = (((((b1 * 256) + b2) * 256) + b3) * 256) + b4;
+ prefixlen = 0;
+ while (netmask > 0)
+ {
+ ++prefixlen;
+ netmask <<= 1;
+ }
+ }
+ else if (sscanf(mask, "%d", &prefixlen) != 1 || prefixlen < 0)
{
tcpd_warn ("Wrong prefix length in %s", tok);
return (NO);