pidgin/pidgin

Fix segmentation fault on IRC server reply
release-2.x.y
23 months ago, Belgin Știrbu
31b24663dd5f
Parents 1912d331d78c
Children 536fd9c928aa
Fix segmentation fault on IRC server reply

When Pidgin received `:nick!user@host JOIN #channel` from an IRC
server, it worked fine, but when it received
`:nick JOIN #channel`, it crashed with a segmentation fault.

Testing Done:
Tested with a custom IRC server that only sends the nickname. Also tested on Libera Chat.

Bugs closed: PIDGIN-17375

Reviewed at https://reviews.imfreedom.org/r/1484/
--- a/libpurple/protocols/irc/msgs.c Fri May 27 03:32:41 2022 -0500
+++ b/libpurple/protocols/irc/msgs.c Mon May 30 20:52:30 2022 -0500
@@ -71,7 +71,14 @@
static char *irc_mask_userhost(const char *mask)
{
- return g_strdup(strchr(mask, '!') + 1);
+ char *sep = strchr(mask, '!');
+ char *host = "";
+
+ if(sep) {
+ host = sep + 1;
+ }
+
+ return g_strdup(host);
}
static void irc_chat_remove_buddy(PurpleConversation *convo, char *data[2])