about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2023-02-07 11:17:48 -0500
committerJune McEnroe <june@causal.agency>2023-02-07 11:17:48 -0500
commit625de6979e28269bf27b9d35f4e2bb030ad2920a (patch)
treefcf7dae5e1868ece448d0bbb00c156afb7272a7b
parentFix segfault parsing line with only tags (diff)
downloadpounce-625de6979e28269bf27b9d35f4e2bb030ad2920a.tar.gz
pounce-625de6979e28269bf27b9d35f4e2bb030ad2920a.zip
Set msg.cmd to NULL if it is empty string
This fixes allowing empty lines from clients during registration.
-rw-r--r--bounce.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/bounce.h b/bounce.h
index 93a3c89..a197053 100644
--- a/bounce.h
+++ b/bounce.h
@@ -72,6 +72,7 @@ static inline struct Message parse(char *line) {
 	if (line && line[0] == '@') msg.tags = 1 + strsep(&line, " ");
 	if (line && line[0] == ':') msg.origin = 1 + strsep(&line, " ");
 	msg.cmd = strsep(&line, " ");
+	if (msg.cmd && !msg.cmd[0]) msg.cmd = NULL;
 	for (size_t i = 0; line && i < ParamCap; ++i) {
 		if (line[0] == ':') {
 			msg.params[i] = &line[1];