From 6dfd66ed66b86341eef9efec183995c7e3fd9fb2 Mon Sep 17 00:00:00 2001 From: m1ngsama Date: Sun, 19 Apr 2026 19:05:57 +0800 Subject: [PATCH] fix: suppress GCC format-truncation warning in exec /me handler --- src/ssh_server.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ssh_server.c b/src/ssh_server.c index a4b5be0..1c4d98a 100644 --- a/src/ssh_server.c +++ b/src/ssh_server.c @@ -1009,7 +1009,10 @@ static int exec_command_post(client_t *client, const char *args) { if (strncmp(content, "/me ", 4) == 0 && content[4] != '\0') { msg.username[0] = '*'; msg.username[1] = '\0'; - snprintf(msg.content, sizeof(msg.content), "%s %s", username, content + 4); + int n = snprintf(msg.content, sizeof(msg.content), "%s %s", username, content + 4); + if (n >= (int)sizeof(msg.content)) { + msg.content[sizeof(msg.content) - 1] = '\0'; + } } else { strncpy(msg.username, username, sizeof(msg.username) - 1); msg.username[sizeof(msg.username) - 1] = '\0';