SHA256
3
0
forked from pool/tcpd
tcpd/tcp_wrappers_7.6-ipv6.fix.fix.diff

31 lines
922 B
Diff

--- hosts_access.c 2003/03/15 15:12:36 1.1
+++ hosts_access.c 2003/03/15 15:47:18
@@ -354,7 +354,26 @@
/* 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);