Default ?block (etc) to G-line by IP; fix a buffer issue.
authorMichael Poole <mdpoole@troilus.org>
Thu, 13 Oct 2005 02:20:55 +0000 (02:20 +0000)
committerMichael Poole <mdpoole@troilus.org>
Thu, 13 Oct 2005 02:20:55 +0000 (02:20 +0000)
src/opserv.c (opserv_block): Rewrite to block by IP rather than
    hostname.
  (opserv_new_user_check): Avoid overrunning the target buffer.
git-archimport-id: srvx@srvx.net--2005-srvx/srvx--devo--1.3--patch-30

ChangeLog
src/opserv.c

index 11f4bf2edc2b5de00eb47069bb0876b3a419f0cb..deed89ccc20a5de822437a30a20508d3bc9b09d5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,21 @@
 # arch-tag: automatic-ChangeLog--srvx@srvx.net--2005-srvx/srvx--devo--1.3
 #
 
+2005-10-13 02:20:55 GMT        Michael Poole <mdpoole@troilus.org>     patch-30
+
+    Summary:
+      Default ?block (etc) to G-line by IP; fix a buffer issue.
+    Revision:
+      srvx--devo--1.3--patch-30
+
+    src/opserv.c (opserv_block): Rewrite to block by IP rather than
+        hostname.
+      (opserv_new_user_check): Avoid overrunning the target buffer.
+
+    modified files:
+     ChangeLog src/opserv.c
+
+
 2005-10-08 14:56:31 GMT        Michael Poole <mdpoole@troilus.org>     patch-29
 
     Summary:
index 7aed1109f3d8b3e0b119177bf67e05967334050b..f7457565dd1d381c202e959ece7b526e3349f1f6 100644 (file)
@@ -754,14 +754,13 @@ static MODCMD_FUNC(cmd_restart)
 static struct gline *
 opserv_block(struct userNode *target, char *src_handle, char *reason, unsigned long duration)
 {
-    char *mask;
-    mask = alloca(MAXLEN);
-    snprintf(mask, MAXLEN, "*@%s", target->hostname);
-    if (!reason) {
-        reason = alloca(MAXLEN);
-        snprintf(reason, MAXLEN, "G-line requested by %s.", src_handle);
-    }
-    if (!duration) duration = opserv_conf.block_gline_duration;
+    char mask[IRC_NTOP_MAX_SIZE+3] = { '*', '@', '\0' };
+    irc_ntop(mask + 2, sizeof(mask) - 2, &target->ip);
+    if (!reason)
+        snprintf(reason = alloca(MAXLEN), MAXLEN,
+                 "G-line requested by %s.", src_handle);
+    if (!duration)
+        duration = opserv_conf.block_gline_duration;
     return gline_add(src_handle, mask, duration, reason, now, 1);
 }
 
@@ -1782,8 +1781,8 @@ opserv_new_user_check(struct userNode *user)
             for (nn=0; nn<ohi->clients.used; nn++)
                 send_message(ohi->clients.list[nn], opserv, "OSMSG_CLONE_WARNING");
         } else if (ohi->clients.used > limit) {
-            char target[18];
-            sprintf(target, "*@%s", addr);
+            char target[IRC_NTOP_MAX_SIZE + 3] = { '*', '@', '\0' };
+            strcpy(target + 2, addr);
             gline_add(opserv->nick, target, opserv_conf.clone_gline_duration, "AUTO Excessive connections from a single host.", now, 1);
         }
     }