]> jfr.im git - irc/quakenet/newserv.git/blobdiff - helpmod2/hlamer.c
GLINES: fix null pointer deref in trustgline / trustungline
[irc/quakenet/newserv.git] / helpmod2 / hlamer.c
index 7824987af74665fe41a755be1d4af4337ffb4a6b..7df076541ee4a7ff29a38bd8f64baaf8078a4b99 100644 (file)
@@ -2,8 +2,6 @@
 #include <ctype.h>
 #include <stdlib.h>
 
-#include "../nick/nick.h"
-
 #include "huser.h"
 #include "hban.h"
 #include "hchannel.h"
@@ -105,10 +103,26 @@ static int hlc_check_caps(hlc_profile *hlc_prof, huser *husr, const char *line)
     int caps = 0;
     int noncaps = 0;
     int i;
+    int firstword;
+
+    if (strchr(line, ' '))
+       firstword = strchr(line, ' ') - line;
+    else
+        firstword = 0;
 
     /* Handle the thing sent with /me */
-    if (!strncmp(line, "\0x01ACTION", 6 + 1))
-        line+=(6 + 1);
+    if (!strncmp(line, "\1ACTION", 6 + 1))
+       line+=(6 + 1);
+    else if (firstword && firstword < NICKLEN + 3)
+    {
+       char buffer[NICKLEN + 3];
+       strncpy(buffer, line, firstword);
+       buffer[firstword] = '\0';
+       if (buffer[firstword - 1] == ':')
+           buffer[firstword - 1] = '\0';
+       if (getnickbynick(buffer))
+            line+=firstword + 1;
+    }
 
     for (i = 0;line[i];i++)
     {
@@ -153,7 +167,7 @@ static int hlc_check_character_repeats(hlc_profile *hlc_prof, huser *husr, const
 {
     char chr = '\0';
     int i;
-    int repeats;
+    int repeats = 0;
 
     for (i = 0;line[i];i++)
         if (line[i] == chr)
@@ -200,12 +214,12 @@ static int hlc_check_flood(hlc_profile *hlc_prof, huser *husr, const char *line)
 
 static int hlc_check_spam(hlc_profile *hlc_prof, huser *husr, const char *line)
 {
-    if (husr->spam_val < (float)time(NULL))
-        husr->spam_val = (float)time(NULL);
+    if (husr->spam_val < (double)time(NULL))
+        husr->spam_val = (double)time(NULL);
 
-    husr->spam_val += (hlc_prof->constant_spam * (double)strlen(line));
+    husr->spam_val += ((double)(hlc_prof->constant_spam) * (double)strlen(line));
 
-    if (((int)husr->spam_val - time(NULL)) >= (hlc_prof->tolerance_spam))
+    if (((int)(husr->spam_val) - time(NULL)) >= (hlc_prof->tolerance_spam))
     {
         husr->spam_val = time(NULL);
         return ++husr->lc[HLC_SPAM];
@@ -256,4 +270,3 @@ const char *hlc_get_violation_name(hlc_violation violation)
         return "Error, please contact strutsi";
     }
 }
-