ircd_string.c: Support abcd* in ipmask_parse().
[ircu2.10.12-pk.git] / ircd / ircd_string.c
index a9d945138aed394032ca597bb9d291b1d79e625f..7785d58c60d57d9bccab5230b2f7c1040caf2950 100644 (file)
@@ -481,12 +481,14 @@ ircd_aton_ip4(const char *input, unsigned int *output, unsigned char *pbits)
       *pbits = bits;
     return pos;
   case '.':
+    if (++dots > 3)
+      return 0;
     if (input[++pos] == '.')
       return 0;
-    ip |= part << (24 - 8 * dots++);
+    ip |= part << (32 - 8 * dots);
     part = 0;
     if (input[pos] == '*') {
-      while (input[++pos] == '*') ;
+      while (input[++pos] == '*' || input[pos] == '.') ;
       if (input[pos] != '\0')
         return 0;
       if (pbits)
@@ -604,9 +606,11 @@ 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 (part && ii < 8)
+          ip->in6_16[ii++] = htons(part);
       if (pbits)
         *pbits = ii * 16;
       return pos;
@@ -620,6 +624,8 @@ ipmask_parse(const char *input, struct irc_in_addr *ip, unsigned char *pbits)
     default:
       return 0;
     }
+    if (input[pos] != '\0')
+      return 0;
   finish:
     if (colon < 8) {
       unsigned int jj;