Commit f9adc3ae authored by Luke Bratch's avatar Luke Bratch
Browse files

Make sure nicks passed to the "update all channels" functions have non-zero...

Make sure nicks passed to the "update all channels" functions have non-zero lengths to avoid an enormous loop.
parent 406864e0
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment