* Reject durations containing invalid characters (like "1day" instead of "1d").
[srvx.git] / src / tools.c
index 6883b7122851d4418388fd77ac99688020b9c916..983fe9fbddcd72c436e8ba04049b61b946e97854 100644 (file)
@@ -313,7 +313,7 @@ irc_pton(irc_in_addr_t *addr, unsigned char *bits, const char *input)
                 addr->in6[cpos + jj] = 0;
         }
     } else if (dot) {
-        unsigned int ip4;
+        uint32_t ip4;
         pos = irc_pton_ip4(input, bits, &ip4);
         if (pos) {
             addr->in6[5] = htons(65535);
@@ -538,7 +538,7 @@ match_ircglob(const char *text, const char *glob)
         m++;
         /* allow escaping to force capitalization */
         if (*m++ != *n++)
-            return 0;
+            goto backtrack;
         break;
     case '*': case '?':
         for (star_p = 0; ; m++) {
@@ -614,7 +614,8 @@ user_matches_glob(struct userNode *user, const char *orig_glob, int flags)
             return 1;
     }
     /* If only matching the visible hostnames, bail early. */
-    if ((flags & MATCH_VISIBLE) && (IsFakeHost(user) || IsHiddenHost(user)))
+    if ((flags & MATCH_VISIBLE) && IsHiddenHost(user)
+        && (IsFakeHost(user) || (hidden_host_suffix && user->handle_info)))
         return 0;
     /* If it might be an IP glob, test that. */
     if (!glob[strspn(glob, "0123456789./*?")]
@@ -793,12 +794,14 @@ ParseInterval(const char *interval)
 
     /* process the string, resetting the count if we find a unit character */
     while ((c = *interval++)) {
-       if (isdigit((int)c)) {
-           partial = partial*10 + c - '0';
-       } else {
-           seconds += TypeLength(c) * partial;
-           partial = 0;
-       }
+        if (isdigit((int)c)) {
+            partial = partial*10 + c - '0';
+        } else if (strchr("yMwdhms", c)) {
+            seconds += TypeLength(c) * partial;
+            partial = 0;
+        } else {
+            return 0;
+        }
     }
     /* assume the last chunk is seconds (the normal case) */
     return seconds + partial;