about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-04-05 13:00:05 -0400
committerJune McEnroe <june@causal.agency>2020-04-05 13:00:05 -0400
commite7f73d66da51be79776c9c28ed4738a5635a1c8a (patch)
treee42b324c9645ef3fc9a79ef764c4f79ebc4ae378
parentOnly set RCS on FreeBSD (diff)
downloadlitterbox-e7f73d66da51be79776c9c28ed4738a5635a1c8a.tar.gz
litterbox-e7f73d66da51be79776c9c28ed4738a5635a1c8a.zip
Error on invalid ISUPPORT values 1.2
-rw-r--r--litterbox.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/litterbox.c b/litterbox.c
index 4a65166..08b98ac 100644
--- a/litterbox.c
+++ b/litterbox.c
@@ -177,12 +177,22 @@ static void handleReplyISupport(struct Message *msg) {
 			set(&chanTypes, msg->params[i]);
 		} else if (!strcmp(key, "PREFIX")) {
 			strsep(&msg->params[i], "(");
-			set(&prefixModes, strsep(&msg->params[i], ")"));
+			char *modes = strsep(&msg->params[i], ")");
+			if (!modes || !msg->params[i]) {
+				errx(EX_PROTOCOL, "invalid PREFIX value");
+			}
+			set(&prefixModes, modes);
 			set(&prefixes, msg->params[i]);
 		} else if (!strcmp(key, "CHANMODES")) {
-			set(&listModes, strsep(&msg->params[i], ","));
-			set(&paramModes, strsep(&msg->params[i], ","));
-			set(&setParamModes, strsep(&msg->params[i], ","));
+			char *list = strsep(&msg->params[i], ",");
+			char *param = strsep(&msg->params[i], ",");
+			char *setParam = strsep(&msg->params[i], ",");
+			if (!list || !param || !setParam) {
+				errx(EX_PROTOCOL, "invalid CHANMODES value");
+			}
+			set(&listModes, list);
+			set(&paramModes, param);
+			set(&setParamModes, setParam);
 		}
 	}
 }