diff options
author | June McEnroe <june@causal.agency> | 2020-04-05 13:00:05 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2020-04-05 13:00:05 -0400 |
commit | e7f73d66da51be79776c9c28ed4738a5635a1c8a (patch) | |
tree | e42b324c9645ef3fc9a79ef764c4f79ebc4ae378 | |
parent | Only set RCS on FreeBSD (diff) | |
download | litterbox-e7f73d66da51be79776c9c28ed4738a5635a1c8a.tar.gz litterbox-e7f73d66da51be79776c9c28ed4738a5635a1c8a.zip |
Error on invalid ISUPPORT values 1.2
-rw-r--r-- | litterbox.c | 18 |
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(¶mModes, 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(¶mModes, param); + set(&setParamModes, setParam); } } } |