diff --git a/CHANGELOG.md b/CHANGELOG.md index a7aec7be9..4592de31d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ ### Fixed +- core: fix possible buffer overflow in command /color alias ([#2330](https://github.com/weechat/weechat/issues/2330)) - core: fix buffer overflow in connection to SOCKS5 proxy ([#2325](https://github.com/weechat/weechat/issues/2325)) - api: fix infinite loop in function string_replace when the search string is empty - irc: limit size of data received from the server to prevent memory exhaustion diff --git a/src/core/core-command.c b/src/core/core-command.c index 1cf4f6bd7..42141c74f 100644 --- a/src/core/core-command.c +++ b/src/core/core-command.c @@ -1711,17 +1711,12 @@ COMMAND_CALLBACK(color) else str_alias = argv[i]; } - str_color[0] = '\0'; - if (str_alias) - { - strcat (str_color, ";"); - strcat (str_color, str_alias); - } - if (str_rgb) - { - strcat (str_color, ";"); - strcat (str_color, str_rgb); - } + snprintf (str_color, sizeof (str_color), + "%s%s%s%s", + (str_alias) ? ";" : "", + (str_alias) ? str_alias : "", + (str_rgb) ? ";" : "", + (str_rgb) ? str_rgb : ""); /* add color alias */ snprintf (str_command, sizeof (str_command),