From 2d0166badbf099b5e992ba56a4f029fc390da0f2 Mon Sep 17 00:00:00 2001 From: cloudwalk Date: Sat, 27 Jun 2020 02:27:21 +0000 Subject: [PATCH] Fix buffer position check Fix by terencehill git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12740 d7cf8633-e32d-0410-b094-e92efae38249 --- console.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/console.c b/console.c index 637599c0..95aaa5a1 100644 --- a/console.c +++ b/console.c @@ -2758,7 +2758,7 @@ int Nicks_CompleteChatLine(char *buffer, size_t size, unsigned int pos) msg = Nicks_list[0]; len = min(size - Nicks_matchpos - 3, strlen(msg)); memcpy(&buffer[Nicks_matchpos], msg, len); - if( len < (size - 7) ) // space for color (^[0-9] or ^xrgb) and space and \0 + if(len < size - 7) // space for color code (^[0-9] or ^xrgb), space and \0 len = (int)Nicks_AddLastColor(buffer, Nicks_matchpos+(int)len); buffer[len++] = ' '; buffer[len] = 0; @@ -3072,7 +3072,7 @@ done: memcpy(&key_line[key_linepos] , Nicks_list[0], cmd_len); key_linepos += cmd_len; - if(key_linepos < (int)(sizeof(key_line)-4)) // space for ^, X and space and \0 + if(key_linepos < (int)(sizeof(key_line) - 7)) // space for color code (^[0-9] or ^xrgb), space and \0 key_linepos = Nicks_AddLastColor(key_line, key_linepos); } key_line[key_linepos++] = ' '; -- 2.39.2