From 50d29b1f290b7ca67f11c2ac41172c6685e155bc Mon Sep 17 00:00:00 2001 From: Tim Cava Date: Sun, 13 Oct 2013 18:48:42 +0000 Subject: [PATCH] Use strlcat, rather than strmcat, in command_completion(). Pass sizeof buffer, rather than a constant, to snprintf and strlcat. git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@384 13b04d17-f746-0410-82c6-800466cd88b0 --- source/commands.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/source/commands.c b/source/commands.c index cc88953..f571774 100644 --- a/source/commands.c +++ b/source/commands.c @@ -4199,7 +4199,7 @@ void command_completion(char unused, char *not_used) #ifdef WANT_DLL IrcCommandDll *dll = NULL; #endif - char buffer[BIG_BUFFER_SIZE + 1]; + char buffer[BIG_BUFFER_SIZE]; malloc_strcpy(&line, get_input()); @@ -4255,7 +4255,7 @@ void command_completion(char unused, char *not_used) #endif if ((alias_cnt == 1) && (cmd_cnt == 0) && (dll_cnt <= 0)) { - snprintf(buffer, BIG_BUFFER_SIZE, "%s%s %s", firstcmdchar, *aliases, rest); + snprintf(buffer, sizeof buffer, "%s%s %s", firstcmdchar, *aliases, rest); set_input(buffer); new_free((char **)aliases); new_free((char **)&aliases); @@ -4270,7 +4270,7 @@ void command_completion(char unused, char *not_used) #endif )) { - snprintf(buffer, BIG_BUFFER_SIZE, "%s%s%s %s", + snprintf(buffer, sizeof buffer, "%s%s%s %s", firstcmdchar, do_aliases ? empty_string : firstcmdchar, #ifdef WANT_DLL @@ -4293,8 +4293,8 @@ void command_completion(char unused, char *not_used) { if (i == 0) bitchsay("Commands:"); - strmcat(buffer, command[i].name, BIG_BUFFER_SIZE); - strmcat(buffer, space, BIG_BUFFER_SIZE); + strlcat(buffer, command[i].name, sizeof buffer); + strlcat(buffer, space, sizeof buffer); if (++c == 4) { put_it("%s", convert_output_format("$G $[15]0 $[15]1 $[15]2 $[15]3", "%s", buffer)); @@ -4313,8 +4313,8 @@ void command_completion(char unused, char *not_used) { if (com && *com && my_strnicmp(com, dll->name, strlen(com))) continue; - strmcat(buffer, dll->name, BIG_BUFFER_SIZE); - strmcat(buffer, space, BIG_BUFFER_SIZE); + strlcat(buffer, dll->name, sizeof buffer); + strlcat(buffer, space, sizeof bufer); if (++c == 4) { put_it("%s", convert_output_format("$G $[15]0 $[15]1 $[15]2 $[15]3", "%s", buffer)); @@ -4334,8 +4334,8 @@ void command_completion(char unused, char *not_used) { if (i == 0) bitchsay("Aliases:"); - strmcat(buffer, aliases[i], BIG_BUFFER_SIZE); - strmcat(buffer, space, BIG_BUFFER_SIZE); + strlcat(buffer, aliases[i], sizeof buffer); + strlcat(buffer, space, sizeof buffer); if (++c == 4) { put_it("%s", convert_output_format("$G $[15]0 $[15]1 $[15]2 $[15]3", "%s", buffer)); @@ -4356,8 +4356,8 @@ void command_completion(char unused, char *not_used) { if (i == 0) bitchsay("Functions:"); - strmcat(buffer, functions[i], BIG_BUFFER_SIZE); - strmcat(buffer, space, BIG_BUFFER_SIZE); + strlcat(buffer, functions[i], sizeof buffer); + strlcat(buffer, space, sizeof buffer); if (++c == 4) { put_it("%s", convert_output_format("$G $[15]0 $[15]1 $[15]2 $[15]3", "%s", buffer));