]> PatchyGit - patchyircd.git/commitdiff
irc: use snprintf for nuh concatenation
authorEgor <egor@patchysicp.xyz>
Wed, 25 Feb 2026 01:03:21 +0000 (03:03 +0200)
committerEgor <egor@patchysicp.xyz>
Wed, 25 Feb 2026 01:03:21 +0000 (03:03 +0200)
src/irc.cpp
src/util.hpp

index 6aed8b6..ad26b36 100644 (file)
@@ -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) {
index d0fee34..80bc681 100644 (file)
@@ -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);