From: Michael Poole Date: Thu, 13 Oct 2005 02:20:55 +0000 (+0000) Subject: Default ?block (etc) to G-line by IP; fix a buffer issue. X-Git-Tag: v1.4.0-rc1~162 X-Git-Url: http://git.pk910.de/?p=srvx.git;a=commitdiff_plain;h=fcb1c7816df34f42bdfa36501e761d5af0ee3508 Default ?block (etc) to G-line by IP; fix a buffer issue. 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 --- diff --git a/ChangeLog b/ChangeLog index 11f4bf2..deed89c 100644 --- 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 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 patch-29 Summary: diff --git a/src/opserv.c b/src/opserv.c index 7aed110..f745756 100644 --- a/src/opserv.c +++ b/src/opserv.c @@ -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; nnclients.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); } }