From df1e5613786ab7e0a40a42bd339e30355bc75165 Mon Sep 17 00:00:00 2001 From: C. McEnroe Date: Sun, 15 Aug 2021 12:24:15 -0400 Subject: Handle tags without values Otherwise a tag with no value would cause a segfault trying to unescape the NULL tag pointer. This shouldn't happen for the server tags we parse, but clients could send @+draft/reply with no value. --- irc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/irc.c b/irc.c index 2d7f23d..8d5ae81 100644 --- a/irc.c +++ b/irc.c @@ -250,8 +250,12 @@ static struct Message parse(char *line) { char *key = strsep(&tag, "="); for (uint i = 0; i < TagCap; ++i) { if (strcmp(key, TagNames[i])) continue; - unescape(tag); - msg.tags[i] = tag; + if (tag) { + unescape(tag); + msg.tags[i] = tag; + } else { + msg.tags[i] = ""; + } break; } } -- cgit 1.4.1-2-gfad0