From bb531a71b14a43923d8c8f8cd44564b655aa7dee Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Sun, 5 Apr 2020 13:11:19 -0400 Subject: Error on invalid ISUPPORT values --- handle.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'handle.c') 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")) { -- cgit 1.4.0 n value='committer'>committer
path: root/log.c (unfollow)
Commit message (Collapse)Author
2021-01-23Drop exec capability iff restrictedKlemens Nanni
Nothing must be executed when running /copy, et al.
2021-01-23Drop network capability after ircConnect()Klemens Nanni
catgirl has no reconnect feature and generally must not do anything but read/write from/to the connected socket which does not require "inet" or "dns" promises.
2021-01-23Call pledge(2) after unveil(2)Klemens Nanni
Simplify logic, be more idiomatic and finalize by pledging after all unveiling is done by omitting the "unveil" promise and thereby not allowing further calls to it.
2021-01-23Separate kiosk mode from restrict modeJune McEnroe
Restrict mode will focus on sandboxing, while kiosk will continue to restrict IRC access through a public kiosk. Kiosk mode without restrict mode allows execution of man 1 catgirl with /help, assuming external sandboxing. The /list and /part commands are also added to the list of disabled commands in kiosk mode, since they are pointless without access to /join.
2021-01-21Simplify windowUpdate loops and factor out windowTopJune McEnroe
No idea why I made that more complicated than it had to be looping backwards.
2021-01-21Document that M-l shows timestampsJune McEnroe
2021-01-19Don't lose swapped window when navigating to current bufferJeremy O'Brien
2021-01-19Use Warm heat for manually inserted blank linesJune McEnroe
Oops, forgot about these.
2021-01-18Add example tmux(1) configKlemens Nanni
Spawn one catgirl per network and handle reconnects through tmux, no extra tool required.
2021-01-17Use Warm heat for blank linesJune McEnroe
So they're not hidden by M-+.
2021-01-16Add -I highlight option and /highlightJune McEnroe