diff --git a/src/interface/chat.c b/src/interface/chat.c index 1c772db0ae..8aaf221aef 100644 --- a/src/interface/chat.c +++ b/src/interface/chat.c @@ -24,11 +24,6 @@ #include "../platform/platform.h" #include "../util/util.h" -#define CHAT_HISTORY_SIZE 10 -#define CHAT_INPUT_SIZE 256 -#define CHAT_MAX_MESSAGE_LENGTH 200 -#define CHAT_MAX_WINDOW_WIDTH 600 - bool gChatOpen = false; char _chatCurrentLine[CHAT_MAX_MESSAGE_LENGTH]; char _chatHistory[CHAT_HISTORY_SIZE][CHAT_INPUT_SIZE]; diff --git a/src/interface/chat.h b/src/interface/chat.h index 48449d1095..f18cf03182 100644 --- a/src/interface/chat.h +++ b/src/interface/chat.h @@ -20,6 +20,11 @@ #include "../common.h" #include "../drawing/drawing.h" +#define CHAT_HISTORY_SIZE 10 +#define CHAT_INPUT_SIZE 1024 +#define CHAT_MAX_MESSAGE_LENGTH 200 +#define CHAT_MAX_WINDOW_WIDTH 600 + extern bool gChatOpen; void chat_open(); diff --git a/src/network/network.cpp b/src/network/network.cpp index 127fc5059c..dae607a579 100644 --- a/src/network/network.cpp +++ b/src/network/network.cpp @@ -2152,13 +2152,13 @@ void network_chat_show_server_greeting() { const char* greeting = gConfigNetwork.server_greeting; if (!str_is_null_or_empty(greeting)) { - static char greeting_formatted[256]; + static char greeting_formatted[CHAT_INPUT_SIZE]; char* lineCh = greeting_formatted; greeting_formatted[0] = 0; lineCh = utf8_write_codepoint(lineCh, FORMAT_OUTLINE); lineCh = utf8_write_codepoint(lineCh, FORMAT_GREEN); char* ptrtext = lineCh; - safe_strcpy(lineCh, greeting, 240); + safe_strcpy(lineCh, greeting, CHAT_INPUT_SIZE - 24); // Limit to 1000 characters so we don't overflow the buffer utf8_remove_format_codes((utf8*)ptrtext, true); chat_history_add(greeting_formatted); }