summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--handle.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/handle.c b/handle.c
index 00e854c..8e91810 100644
--- a/handle.c
+++ b/handle.c
@@ -248,17 +248,26 @@ static void handleReplyISupport(struct Message *msg) {
 			if (!msg->params[i]) continue;
 			set(&network.chanTypes, msg->params[i]);
 		} else if (!strcmp(key, "PREFIX")) {
-			if (!msg->params[i]) continue;
 			strsep(&msg->params[i], "(");
-			set(&network.prefixModes, strsep(&msg->params[i], ")"));
-			set(&network.prefixes, msg->params[i]);
-			assert(strlen(network.prefixes) == strlen(network.prefixModes));
+			char *modes = strsep(&msg->params[i], ")");
+			char *prefixes = msg->params[i];
+			if (!modes || !prefixes || strlen(modes) != strlen(prefixes)) {
+				errx(EX_PROTOCOL, "invalid PREFIX value");
+			}
+			set(&network.prefixModes, modes);
+			set(&network.prefixes, prefixes);
 		} else if (!strcmp(key, "CHANMODES")) {
-			if (!msg->params[i]) continue;
-			set(&network.listModes, strsep(&msg->params[i], ","));
-			set(&network.paramModes, strsep(&msg->params[i], ","));
-			set(&network.setParamModes, strsep(&msg->params[i], ","));
-			set(&network.channelModes, strsep(&msg->params[i], ","));
+			char *list = strsep(&msg->params[i], ",");
+			char *param = strsep(&msg->params[i], ",");
+			char *setParam = strsep(&msg->params[i], ",");
+			char *channel = strsep(&msg->params[i], ",");
+			if (!list || !param || !setParam || !channel) {
+				errx(EX_PROTOCOL, "invalid CHANMODES value");
+			}
+			set(&network.listModes, list);
+			set(&network.paramModes, param);
+			set(&network.setParamModes, setParam);
+			set(&network.channelModes, channel);
 		} else if (!strcmp(key, "EXCEPTS")) {
 			network.excepts = (msg->params[i] ?: "e")[0];
 		} else if (!strcmp(key, "INVEX")) {
;follow=1'>Handle nick collisionJune McEnroe 2019-10-26Wait for AUTHENTICATE + from serverJune McEnroe 2019-10-26Respond to PING with same parameterJune McEnroe 2019-10-26Add undocumented flag to disable verificationJune McEnroe 2019-10-26Do not require RPL_ISUPPORT for stateReadyJune McEnroe 2019-10-26Implement graceful shutdownJune McEnroe 2019-10-26Require PASS before USERJune McEnroe 2019-10-26Track channel topicsJune McEnroe 2019-10-26Set AWAY when no clients are connectedJune McEnroe 2019-10-26Add flags to request TOPIC and NAMES on client connectJune McEnroe 2019-10-26OopsJune McEnroe 2019-10-26Disconnect client on unknown commandJune McEnroe 2019-10-26Allow reading sensitive information from filesJune McEnroe 2019-10-26Add rc scriptJune McEnroe 2019-10-25Add install and uninstall targetsJune McEnroe 2019-10-25Expand documentationJune McEnroe 2019-10-25Add AGPLv3 notice on client registrationJune McEnroe 2019-10-25Rename project pounceJune McEnroe