]> jfr.im git - irc/quakenet/newserv.git/commitdiff
Fix: check if ->reason is NULL.
authorGunnar Beutner <redacted>
Thu, 25 Jul 2013 20:15:27 +0000 (22:15 +0200)
committerGunnar Beutner <redacted>
Thu, 25 Jul 2013 20:15:27 +0000 (22:15 +0200)
--HG--
branch : shroudtrusts

glines/glines.c
glines/glines_buf.c
glines/glines_handler.c
glines/glines_store.c

index c728be5a52b9b1d183c86be1ad0ff56918359415..8edfc6ddb4006c3e05b2c40680a53182d6d8f5d2 100644 (file)
@@ -173,45 +173,45 @@ void gline_propagate(gline *agline) {
 #else
     controlwall(NO_OPER, NL_GLINES, "Destroying G-Line on '%s' lasting %s with reason '%s', created by: %s",
       glinetostring(agline), longtoduration(agline->expire-getnettime(), 0),
-      agline->reason->content, agline->creator->content);
+      agline->reason ? agline->reason->content : "", agline->creator->content);
 
 #if 1
     irc_send("%s GL * %%-%s %lu %lu :%s\r\n", mynumeric->content,
       glinetostring(agline), agline->expire - getnettime(),
-      agline->lastmod, agline->reason->content);
+      agline->lastmod, agline->reason ? agline->reason->content : "");
 #else
     controlwall(NO_OPER, NL_GLINES, "%s GL * %%-%s %lu %lu :%s\r\n", mynumeric->content,
       glinetostring(agline), agline->expire - getnettime(),
-      agline->lastmod, agline->reason->content);
+      agline->lastmod, agline->reason ? agline->reason->content : "");
 #endif
 #endif /* SNIRCD_VERSION */
   } else if (agline->flags & GLINE_ACTIVE) {
     controlwall(NO_OPER, NL_GLINES, "Activating G-Line on '%s' lasting %s created by %s with reason '%s'",
       glinetostring(agline), longtoduration(agline->expire-getnettime(), 0),
-      agline->creator->content, agline->reason->content);
+      agline->creator->content, agline->reason ? agline->reason->content : "");
 
 #if 1
     irc_send("%s GL * +%s %lu %lu :%s\r\n", mynumeric->content,
       glinetostring(agline), agline->expire - getnettime(),
-      agline->lastmod, agline->reason->content);
+      agline->lastmod, agline->reason ? agline->reason->content : "");
 #else
     controlwall(NO_OPER, NL_GLINES, "%s GL * +%s %lu %lu :%s\r\n", mynumeric->content,
       glinetostring(agline), agline->expire - getnettime(),
-      agline->lastmod, agline->reason->content);
+      agline->lastmod, agline->reason ? agline->reason->content : "");
 #endif
   } else {
     controlwall(NO_OPER, NL_GLINES, "Deactivating G-Line on '%s' lasting %s created by %s with reason '%s'",
       glinetostring(agline), longtoduration(agline->expire-getnettime(), 0),
-      agline->creator->content, agline->reason->content);
+      agline->creator->content, agline->reason ? agline->reason->content : "");
 
 #if 1
     irc_send("%s GL * -%s %lu %lu :%s\r\n", mynumeric->content,
       glinetostring(agline), agline->expire - getnettime(),
-      agline->lastmod, agline->reason->content);
+      agline->lastmod, agline->reason ? agline->reason->content : "");
 #else
     controlwall(NO_OPER, NL_GLINES, "%s GL * -%s %lu %lu :%s\r\n", mynumeric->content,
       glinetostring(agline), agline->expire - getnettime(),
-      agline->lastmod, agline->reason->content);
+      agline->lastmod, agline->reason ? agline->reason->content : "");
 #endif
   }
 }
@@ -302,7 +302,7 @@ int isglinesane(gline *gl, const char **hint) {
   trusthost *th;
 
   /* Reason is too short */
-  if (strlen(gl->reason->content) < MINGLINEREASONLEN) {
+  if (!gl->reason || strlen(gl->reason->content) < MINGLINEREASONLEN) {
     *hint = "G-Line reason is too short.";
     return 0;
   }
@@ -414,7 +414,7 @@ gline *glinedup(gline *gl) {
   if (gl->host)
     sgl->host = getsstring(gl->host->content, 512);
 
-  sgl->reason = getsstring(gl->reason->content, 512);
+  sgl->reason = gl->reason ? getsstring(gl->reason->content, 512) : NULL;
   sgl->creator = getsstring(gl->creator->content, 512);
 
   memcpy(&sgl->ip, &gl->ip, sizeof(gl->ip));
index 5103f5c68e95bd5fd6cf0c5927ff4e200d9b9c7b..d1a8cd30e4b01e44021a0cef3ea4b79478c59e4d 100644 (file)
@@ -243,7 +243,7 @@ void glinebufspew(glinebuf *gbuf, nick *spewto) {
     else
       strftime(lastmod, sizeof(lastmod), "%d/%m/%y %H:%M:%S", localtime(&gl->lastmod));
 
-    controlreply(spewto, "%-40s %-20s %-20s %-25s %s", glinetostring(gl), timebuf, lastmod, gl->creator->content, gl->reason->content);
+    controlreply(spewto, "%-40s %-20s %-20s %-25s %s", glinetostring(gl), timebuf, lastmod, gl->creator->content, gl->reason ? gl->reason->content : "");
   }
 
   controlreply(spewto, "Hits");
index b1e1ac268f13eab2adbb9cacb4327c1b6b4ba427..6ff22a7ebf62ac5ecec85d631ecad4a34ce66585 100644 (file)
@@ -135,7 +135,7 @@ int handleglinemsg(void *source, int cargc, char **cargv) {
     agline = findgline(mask);
 
     if (agline) {
-      Error("debuggline", ERR_WARNING, "Update for existing gline received for %s - old lastmod %lu, expire %lu, lifetime %lu, reason %s, creator %s", mask, agline->lastmod, agline->expire, agline->lifetime, agline->reason->content, agline->creator->content);
+      Error("debuggline", ERR_WARNING, "Update for existing gline received for %s - old lastmod %lu, expire %lu, lifetime %lu, reason %s, creator %s", mask, agline->lastmod, agline->expire, agline->lifetime, agline->reason ? agline->reason->content : "", agline->creator->content);
 
       agline->flags |= GLINE_ACTIVE;
 
index 0e44d8387181a3d3d9adb8162dd01e942a74fa99..1d5082ae670322f44ba70e412bacc87dc178439e 100644 (file)
@@ -19,7 +19,7 @@ static int glstore_savefile(const char *file) {
     fprintf(fp, "%s %jd,%jd,%jd,%d,%s,%s\n",
       glinetostring(gl), (intmax_t)gl->expire, (intmax_t)gl->lastmod, (intmax_t)gl->lifetime,
       (gl->flags & GLINE_ACTIVE) ? 1 : 0,
-      gl->creator->content, gl->reason->content);
+      gl->creator->content, gl->reason ? gl->reason->content : "");
     count++;
   }