]> jfr.im git - irc/freenode/syn.git/commitdiff
In new-user hooks, blank out the user pointer if we kill it, and don't attempt to...
authorStephen Bennett <redacted>
Wed, 12 Aug 2009 21:12:18 +0000 (22:12 +0100)
committerStephen Bennett <redacted>
Wed, 12 Aug 2009 21:12:44 +0000 (22:12 +0100)
facilities.c
gateways.c
masks.c
tor.c

index 54456b4eda97882db5099cf9e77501923447ad6e..4ee36a257c8c99b1fd66c928dc76722b2ba63c82 100644 (file)
@@ -309,6 +309,10 @@ void facility_newuser(hook_user_data_t *data)
     facility_t *f;
     mowgli_dictionary_iteration_state_t state;
 
+    /* If the user has already been killed, don't try to do anything */
+    if (!u)
+        return;
+
     int blocked = 0, throttled = 0, blacklisted = 0;
     char *blockmessage = NULL, *throttlemessage = NULL;
     facility_cloak_type cloak = facility_cloak_none;
@@ -388,6 +392,7 @@ void facility_newuser(hook_user_data_t *data)
                     throttling_facility->hostpart);
         }
         syn_kill2(u, "Throttled", "%s", throttlemessage);
+        data->u = NULL;
         return;
     }
 
@@ -400,6 +405,7 @@ void facility_newuser(hook_user_data_t *data)
                     u->nick, blocking_facility ? blocking_facility->hostpart : "(unknown)");
         }
         syn_kill2(u, "Facility Blocked", "%s", blockmessage);
+        data->u = NULL;
         return;
     }
 
@@ -412,6 +418,7 @@ void facility_newuser(hook_user_data_t *data)
                     u->nick, blocking_facility->hostpart, blocking_regex);
         }
         syn_kill(u, "%s", blockmessage);
+        data->u = NULL;
         return;
     }
 
index 967a14171883459f201f73df00a655883e031c75..99f32416e415ccfa059f06ea3d22f8bb5273f4c5 100644 (file)
@@ -49,6 +49,10 @@ static void gateway_newuser(hook_user_data_t *data)
     user_t *u = data->u;
     kline_t *k = NULL;
 
+    /* If the user has already been killed, don't try to do anything */
+    if (!u)
+        return;
+
     char *ident = u->user;
     if (*ident == '~')
         ++ident;
@@ -63,6 +67,7 @@ static void gateway_newuser(hook_user_data_t *data)
         {
             syn_report("Killing user %s; hex ident matches K:line [%s@%s] (%s)", u->nick, k->user, k->host, k->reason);
             syn_kill(u, "Your reported IP [%s] is banned: %s", identhost, k->reason);
+            data->u = NULL;
             return;
         }
 
@@ -88,12 +93,14 @@ static void gateway_newuser(hook_user_data_t *data)
     {
         syn_report("Killing user %s; realname host matches K:line [%s@%s] (%s)", u->nick, k->user, k->host, k->reason);
         syn_kill(u, "Your reported hostname [%s] is banned: %s", gecos, k->reason);
+        data->u = NULL;
         return;
     }
     else if ((k = syn_find_kline(NULL, p)))
     {
         syn_report("Killing user %s; realname host matches K:line [%s@%s] (%s)", u->nick, k->user, k->host, k->reason);
         syn_kill(u, "Your reported hostname [%s] is banned: %s", p, k->reason);
+        data->u = NULL;
         return;
     }
 
diff --git a/masks.c b/masks.c
index 3aabe9717aadcb9830184c243efd611208043979..7ded9e3513462d3864ff8a9b93fb75be99b15ccf 100644 (file)
--- a/masks.c
+++ b/masks.c
@@ -207,6 +207,10 @@ void masks_newuser(hook_user_data_t *data)
 {
     user_t *u = data->u;
 
+    /* If the user has already been killed, don't try to do anything */
+    if (!u)
+        return;
+
     char nuh[NICKLEN+USERLEN+HOSTLEN+GECOSLEN];
     snprintf(nuh, sizeof(nuh), "%s!%s@%s %s", u->nick, u->user, u->host, u->gecos);
 
@@ -249,6 +253,7 @@ void masks_newuser(hook_user_data_t *data)
         syn_report("Killing client %s(%s@%s) due to lethal mask %s",
                 u->nick, u->user, u->host, blocked_regex);
         syn_kill_or_kline(u, lethal_mask_duration, lethal_mask_message);
+        data->u = NULL;
         return;
     }
 
diff --git a/tor.c b/tor.c
index 7e12d0d5935cd3807ffdf73faf5503d431d41090..9a49bf1b1a0d9614876f72322c03820919ca7d7c 100644 (file)
--- a/tor.c
+++ b/tor.c
@@ -73,6 +73,10 @@ static void tor_newuser(hook_user_data_t *data)
 {
     user_t *u = data->u;
 
+    /* If the user has already been killed, don't try to do anything */
+    if (!u)
+        return;
+
     if (is_internal_client(u) || *u->ip == '\0')
         return;