summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-04-05 13:17:38 -0400
committerJune McEnroe <june@causal.agency>2020-04-05 13:17:38 -0400
commit1969c9125fbde0d420c22cebc7578b4473a7aac0 (patch)
tree63d81583acb6f6877aaf3a41f9de9949717d1ec6
parentError on invalid ISUPPORT values (diff)
downloadcatgirl-1969c9125fbde0d420c22cebc7578b4473a7aac0.tar.gz
catgirl-1969c9125fbde0d420c22cebc7578b4473a7aac0.zip
Error on missing MODE parameters
-rw-r--r--handle.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/handle.c b/handle.c
index 8e91810..0719754 100644
--- a/handle.c
+++ b/handle.c
@@ -677,7 +677,9 @@ static void handleMode(struct Message *msg) {
 		if (!name) name = "";
 
 		if (strchr(network.prefixModes, *ch)) {
-			assert(i < ParamCap);
+			if (i >= ParamCap || !msg->params[i]) {
+				errx(EX_PROTOCOL, "MODE missing %s parameter", mode);
+			}
 			char *nick = msg->params[i++];
 			char prefix = network.prefixes[
 				strchr(network.prefixModes, *ch) - network.prefixModes
@@ -696,7 +698,9 @@ static void handleMode(struct Message *msg) {
 		}
 
 		if (strchr(network.listModes, *ch)) {
-			assert(i < ParamCap);
+			if (i >= ParamCap || !msg->params[i]) {
+				errx(EX_PROTOCOL, "MODE missing %s parameter", mode);
+			}
 			char *mask = msg->params[i++];
 			if (*ch == 'b') {
 				verb = (set ? "bans" : "unbans");
@@ -727,7 +731,9 @@ static void handleMode(struct Message *msg) {
 		}
 
 		if (strchr(network.paramModes, *ch)) {
-			assert(i < ParamCap);
+			if (i >= ParamCap || !msg->params[i]) {
+				errx(EX_PROTOCOL, "MODE missing %s parameter", mode);
+			}
 			char *param = msg->params[i++];
 			uiFormat(
 				id, Cold, tagTime(msg),
@@ -742,7 +748,9 @@ static void handleMode(struct Message *msg) {
 		}
 
 		if (strchr(network.setParamModes, *ch) && set) {
-			assert(i < ParamCap);
+			if (i >= ParamCap || !msg->params[i]) {
+				errx(EX_PROTOCOL, "MODE missing %s parameter", mode);
+			}
 			char *param = msg->params[i++];
 			uiFormat(
 				id, Cold, tagTime(msg),
2019-01-08Remove incorrect default coordinatesJune McEnroe 2019-01-07Set img src when explore fragment changesJune McEnroe 2019-01-07Compress PNG data in imageJune McEnroe kcgi never enables compression for FastCGI. 2019-01-07madvise MADV_NOCORE in imageJune McEnroe 2019-01-07Add license notice to explore JavaScriptJune McEnroe 2019-01-07Add Q/Home binding in exploreJune McEnroe 2019-01-07Fix explore image URLJune McEnroe 2019-01-07Add HOME button, ssh link, AGPL notice to exploreJune McEnroe 2019-01-06Add meta viewport to exploreJune McEnroe 2019-01-06Set background and max-width in exploreJune McEnroe 2019-01-06Swallow writes after the connection is closedJune McEnroe It was not okay. 2019-01-06Handle KCGI_HUPJune McEnroe I hope it's okay that I keep writing to the fwopen stream after streamWrite returns -1. 2019-01-06Install html filesJune McEnroe