about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2023-07-03 16:23:01 -0400
committerJune McEnroe <june@causal.agency>2023-07-03 16:23:01 -0400
commit69473f70debb76ecd620d52163966c73f48a2f85 (patch)
tree489dc4df77fab54c03ae2108969d870197035738
parentHandle irssi's invalid JOIN during registration (diff)
downloadpounce-69473f70debb76ecd620d52163966c73f48a2f85.tar.gz
pounce-69473f70debb76ecd620d52163966c73f48a2f85.zip
Handle servers not sending NUH-origin in NICK
Apparently Unreal does this. Only having :nick in the NICK would
confuse the check for self.
-rw-r--r--state.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/state.c b/state.c
index 0569902..df000b5 100644
--- a/state.c
+++ b/state.c
@@ -283,9 +283,9 @@ static bool originSelf(const char *origin) {
 	size_t len = strlen(self.nick);
 	if (strlen(origin) < len) return false;
 	if (strncmp(origin, self.nick, len)) return false;
-	if (origin[len] != '!') return false;
+	if (origin[len] && origin[len] != '!') return false;
 
-	if (!self.origin || strcmp(self.origin, origin)) {
+	if (origin[len] && (!self.origin || strcmp(self.origin, origin))) {
 		set(&self.origin, origin);
 	}
 	return true;
@@ -296,6 +296,7 @@ static void handleNick(struct Message *msg) {
 	if (!originSelf(msg->origin)) return;
 	set(&self.nick, msg->params[0]);
 
+	if (!self.origin) return;
 	char *rest = strchr(self.origin, '!');
 	assert(rest);
 	size_t size = strlen(self.nick) + strlen(rest) + 1;