summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-08-15 12:24:15 -0400
committerJune McEnroe <june@causal.agency>2021-08-15 12:24:15 -0400
commitdf1e5613786ab7e0a40a42bd339e30355bc75165 (patch)
tree15ff21d2fb2f7fa121115694c95a1c5cd8535cbf
parentFix missing include for flock(2) (diff)
downloadcatgirl-1.9a.tar.gz
catgirl-1.9a.zip
Handle tags without values 1.9a
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.
-rw-r--r--irc.c8
1 files 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;
 			}
 		}