ref: 43ec71dc8d40b13aa1f14effef68761ff6fe15a1
parent: 6bbc66e7c0951d7f9ec054179867c4a0d839bb26
author: libredev <libredev@ircforever.org>
date: Fri Jan 20 14:02:58 EST 2023
ignore users with big nickname
--- a/main.c
+++ b/main.c
@@ -477,7 +477,7 @@
} else if (strcmp(cmd, "PING") == 0) {
snprintf(msg, sizeof(msg), "PONG %s\r\n", buf);
writeall(fd, msg);
- goto printbuffer;
+ return 0;
}
/* strip nick from first column */
nick = split(&cmd, '!');
@@ -514,7 +514,9 @@
} else if (strcmp(cmd, "433") == 0) { /* Nickname already in use */
split(&buf, ' ');
nick = split(&buf, ' ');
- if (strlen(nick)+1 > NICK_LEN) {
+ strcat(nick, "_");
+ events[id].suffix++;
+ if (strlen(nick) > NICK_LEN) {
warnx("nick '%s' is too big", nick);
if (strcmp(nick, lnick) == 0) {
net_del(networks[netid].name);
@@ -523,8 +525,6 @@
user_del(nick, msg);
}
} else {
- strcat(nick, "_");
- events[id].suffix++;
snprintf(msg, sizeof(msg), "NICK %s\r\n", nick);
writeall(fd, msg);
}
@@ -831,8 +831,10 @@
len = strlen(unick) + strlen(networks[netid].symb) + 2 + 1;
/* too long nick */
- if (len - 1 > NICK_LEN)
+ if (len-1 > NICK_LEN) {
warnx("nick '%s' is too big", unick);
+ return;
+ }
/* resize hash table if storage is low */
if ((users->cap - users->len) < USER_ADDEND)