summaryrefslogtreecommitdiff
path: root/functions.c
diff options
context:
space:
mode:
authorLuke Bratch <luke@bratch.co.uk>2019-09-15 18:01:10 +0100
committerLuke Bratch <luke@bratch.co.uk>2019-09-15 18:01:10 +0100
commitf9adc3ae2f26154ae38c1f3a39d2814f71f0c1e7 (patch)
treee842cfbd3b12c85760a1a5709a98f7e129bbeabc /functions.c
parent406864e0875058f9533c861eaf65d956902bdb96 (diff)
Make sure nicks passed to the "update all channels" functions have non-zero lengths to avoid an enormous loop.
Diffstat (limited to 'functions.c')
-rw-r--r--functions.c12
1 files changed, 12 insertions, 0 deletions
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