From f9adc3ae2f26154ae38c1f3a39d2814f71f0c1e7 Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Sun, 15 Sep 2019 18:01:10 +0100 Subject: Make sure nicks passed to the "update all channels" functions have non-zero lengths to avoid an enormous loop. --- functions.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/functions.c b/functions.c index a8f0927..58be95f 100644 --- a/functions.c +++ b/functions.c @@ -1424,6 +1424,12 @@ int removenickfromallchannels(char *nickuserhost, struct channel *channels) { // Get the nick from the prefix extractnickfromprefix(nickuserhost); + // Make sure the nick has a length of at least one + if (strlen(nickuserhost) < 1) { + debugprint(DEBUG_CRIT, "updatenickinallchannels(): nick has no length, returning 0!\n"); + return 0; + } + // Go through all channels and remove nick if present for (int i = 0; i < MAXCHANNELS; i++) { // Go through all nicks in channel @@ -1451,6 +1457,12 @@ int updatenickinallchannels(char *nickuserhost, char *newnick, struct channel *c // Strip prefix from newnick stripprefix(newnick); + // Make sure the old and new nicks have a length of at least one + if (strlen(nickuserhost) < 1 || strlen(newnick) < 1) { + debugprint(DEBUG_CRIT, "updatenickinallchannels(): nick has no length, returning 0!\n"); + return 0; + } + // Go through all channels and update nick if present for (int i = 0; i < MAXCHANNELS; i++) { // Go through all nicks in channel -- cgit v1.2.3