2012-04-22 04:21:26 +02:00
|
|
|
--- hosts_access.c.orig
|
2008-10-13 18:39:38 +02:00
|
|
|
+++ hosts_access.c
|
2012-04-22 04:21:26 +02:00
|
|
|
@@ -354,7 +354,26 @@ char *string;
|
2006-12-19 00:17:59 +01:00
|
|
|
/* 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);
|