ticl

tiny irc channel linker
git clone git://git.ircforever.org/ticl
Log | Files | Refs | Submodules | README | LICENSE

commit 43ec71dc8d40b13aa1f14effef68761ff6fe15a1
parent 6bbc66e7c0951d7f9ec054179867c4a0d839bb26
Author: libredev <libredev@ircforever.org>
Date:   Fri, 20 Jan 2023 19:02:58 +0530

ignore users with big nickname

Diffstat:
Mmain.c | 12+++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/main.c b/main.c @@ -477,7 +477,7 @@ event_read(int id) } 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 @@ event_read(int id) } 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 @@ event_read(int id) 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 @@ user_add(char *unick, int netid, int clone) 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)