added gnutls backend and moved backend code into new files
[ircu2.10.12-pk.git] / ircd / numnicks.c
index 47b3fec59e2088fc865432ebb0e2695cb591c153..66e432135d23db284df65b3e1c1b0a03518bd2c8 100644 (file)
@@ -502,14 +502,18 @@ void base64toip(const char* input, struct irc_in_addr* addr)
   memset(addr, 0, sizeof(*addr));
   if (strlen(input) == 6) {
     unsigned int in = base64toint(input);
-    addr->in6_16[6] = htons(in >> 16);
-    addr->in6_16[7] = htons(in & 65535);
+    /* An all-zero address should stay that way. */
+    if (in) {
+      addr->in6_16[5] = htons(65535);
+      addr->in6_16[6] = htons(in >> 16);
+      addr->in6_16[7] = htons(in & 65535);
+    }
   } else {
     unsigned int pos = 0;
     do {
       if (*input == '_') {
         unsigned int left;
-        for (left = (25 - strlen(input)) / 3; left; left--)
+        for (left = (25 - strlen(input)) / 3 - pos; left; left--)
           addr->in6_16[pos++] = 0;
         input++;
       } else {
@@ -517,7 +521,6 @@ void base64toip(const char* input, struct irc_in_addr* addr)
         accum = (accum << NUMNICKLOG) | convert2n[(unsigned char)*input++];
         accum = (accum << NUMNICKLOG) | convert2n[(unsigned char)*input++];
         addr->in6_16[pos++] = ntohs(accum);
-        input += 3;
       }
     } while (pos < 8);
   }