]> jfr.im git - irc/rizon/plexus4.git/commitdiff
m_highlight: fix searching past end of message
authorAdam <redacted>
Fri, 28 Jul 2017 20:40:59 +0000 (16:40 -0400)
committerAdam <redacted>
Fri, 28 Jul 2017 20:40:59 +0000 (16:40 -0400)
modules/m_highlight.c

index 9dec7b43be808de6b41ba8c397b35e9c798f85fe..31b6f03f148acdc3098e27a65142849a49c80d74 100644 (file)
@@ -44,8 +44,10 @@ is_masshl(struct Channel *chptr, const char *message)
 
   strlcpy(msg, message, sizeof(msg));
 
-  while (start < msg + sizeof(msg))
+  while (*start)
   {
+    assert(start >= msg && start < msg + sizeof(msg));
+
     // Skip non nick
     while (*start && !IsNickChar(*start))
       ++start;
@@ -57,8 +59,15 @@ is_masshl(struct Channel *chptr, const char *message)
 
     const char *token = start;
 
-    *end = 0; // null end of token
-    start = end + 1; // proceed to next
+    if (*end)
+    {
+      *end = 0; // null end of token
+      start = end + 1; // proceed to next
+    }
+    else
+    {
+      start = end; // end loop
+    }
 
     struct Client *target = hash_find_client(token);