From: Egor Date: Wed, 25 Feb 2026 01:03:21 +0000 (+0200) Subject: irc: use snprintf for nuh concatenation X-Git-Url: https://git.patchysicp.xyz/?a=commitdiff_plain;h=88a40384111b3965b88686ccdfc4306361eb35df;p=patchyircd.git irc: use snprintf for nuh concatenation --- diff --git a/src/irc.cpp b/src/irc.cpp index 6aed8b6..ad26b36 100644 --- a/src/irc.cpp +++ b/src/irc.cpp @@ -1316,8 +1316,9 @@ static void updateNuh(Client *client) { const char *u = client->username ? client->username : "*"; const char *h = client->hostname; delete[] client->nuh; - client->nuh = new char[strlen(n) + strlen(u) + strlen(h) + 3]; - sprintf(client->nuh, "%s!%s@%s", n, u, h); + size_t len = strlen(n) + strlen(u) + strlen(h) + 3; + client->nuh = new char[len]; + snprintf(client->nuh, len, "%s!%s@%s", n, u, h); stringlower(client->nuh); } static bool is_nick_valid(std::string_view nickname) { diff --git a/src/util.hpp b/src/util.hpp index d0fee34..80bc681 100644 --- a/src/util.hpp +++ b/src/util.hpp @@ -20,6 +20,7 @@ void stringlower(char *s); #pragma GCC poison calloc #pragma GCC poison realloc #pragma GCC poison free +#pragma GCC poison sprintf #endif #define strcpy_lit(a, b) memcpy((a), (b), sizeof(b)) char *mystrdup(const char *s);