Match 127.*.*.* masks against IPs in the usually expected manner.
authorMichael Poole <mdpoole@troilus.org>
Tue, 21 Aug 2007 02:02:10 +0000 (02:02 +0000)
committerMichael Poole <mdpoole@troilus.org>
Tue, 21 Aug 2007 02:02:10 +0000 (02:02 +0000)
git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/branches/u2_10_12_branch@1834 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

ChangeLog
ircd/ircd_string.c
ircd/test/ircd_in_addr_t.c

index fe176702e4b6763cbfffd9de0864fea1ac00aef8..303beadfbabb406a214497b9a42742dbb92821c7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2007-08-20  Michael Poole <mdpoole@troilus.org>
+
+       * ircd/ircd_string.c (ircd_aton_ip4): Allow a sequence of *.* at
+       the end of an IPv4 mask.
+       (ipmask_parse): Likewise for *:* at the end of IPv6 masks.
+
+       * ircd/test/ircd_in_addr_t.c (test_masks): Add tests for this.
+
 2007-08-20  Michael Poole <mdpoole@troilus.org>
 
        * ircd/s_user.c (register_user): Update inv_clients and opers
index a9d945138aed394032ca597bb9d291b1d79e625f..1ed082d6f34d6073d5d5d59041b4d8d65c7ad99a 100644 (file)
@@ -486,7 +486,7 @@ ircd_aton_ip4(const char *input, unsigned int *output, unsigned char *pbits)
     ip |= part << (24 - 8 * dots++);
     part = 0;
     if (input[pos] == '*') {
-      while (input[++pos] == '*') ;
+      while (input[++pos] == '*' || input[pos] == '.') ;
       if (input[pos] != '\0')
         return 0;
       if (pbits)
@@ -604,7 +604,7 @@ ipmask_parse(const char *input, struct irc_in_addr *ip, unsigned char *pbits)
       *pbits = part;
       goto finish;
     case '*':
-      while (input[++pos] == '*') ;
+      while (input[++pos] == '*' || input[pos] == ':') ;
       if (input[pos] != '\0' || colon < 8)
         return 0;
       if (pbits)
index 07f6cc96abe9f479be4bfc97e014922a5e7b71d5..1a65aec59eaa20a8f1dca570e8c513d6a1cc608f 100644 (file)
@@ -111,6 +111,7 @@ static struct ipmask_test test_masks[] = {
     { "::10.0.0.0", {{ 0, 0, 0, 0, 0, 0, 0xa00, 0 }}, 1, 1, 128 },
     { "192.168/16", {{ 0, 0, 0, 0, 0, 0xffff, 0xc0a8, 0 }}, 1, 1, 112 },
     { "192.*", {{ 0, 0, 0, 0, 0, 0xffff, 0xc000, 0 }}, 1, 1, 104 },
+    { "192.*.*.*", {{ 0, 0, 0, 0, 0, 0xffff, 0xc000, 0 }}, 1, 1, 104 },
     { "192.*/8", {{ 0, 0, 0, 0, 0, 0, 0, 0 }}, 1, 0, 0 },
     { "192*", {{ 0, 0, 0, 0, 0, 0, 0, 0 }}, 1, 0, 0 },
     { "192.168.0.0/16", {{ 0, 0, 0, 0, 0, 0, 0, 0 }}, 0, 0, 0 },
@@ -120,6 +121,7 @@ static struct ipmask_test test_masks[] = {
     { "a:b", {{ 0, 0, 0, 0, 0, 0, 0, 0 }}, 1, 0, 0 },
     { "a::*", {{ 0, 0, 0, 0, 0, 0, 0, 0 }}, 1, 0, 0 },
     { "a:*", {{ 0xa, 0, 0, 0, 0, 0, 0, 0 }}, 1, 1, 16 },
+    { "a:*:*", {{ 0xa, 0, 0, 0, 0, 0, 0, 0 }}, 1, 1, 16 },
     { "a:/16", {{ 0xa, 0, 0, 0, 0, 0, 0, 0 }}, 1, 1, 16 },
     { 0 }
 };