diff --git a/src/pc/djui/djui_chat_message.c b/src/pc/djui/djui_chat_message.c index 6bb9028a4..dd299af34 100644 --- a/src/pc/djui/djui_chat_message.c +++ b/src/pc/djui/djui_chat_message.c @@ -62,8 +62,8 @@ void djui_chat_message_create_from(u8 globalIndex, const char* message) { } const char* playerColorString = network_get_player_text_color_string(np->localIndex); - char chatMsg[MAX_CHAT_MSG_LENGTH] = { 0 }; - snprintf(chatMsg, MAX_CHAT_MSG_LENGTH, "%s%s\\#dcdcdc\\: %s", playerColorString, (np != NULL) ? np->name : "Player", message); + char chatMsg[MAX_CHAT_PACKET_LENGTH] = { 0 }; + snprintf(chatMsg, MAX_CHAT_PACKET_LENGTH, "%s%s\\#dcdcdc\\: %s", playerColorString, (np != NULL) ? np->name : "Player", message); play_sound((globalIndex == gNetworkPlayerLocal->globalIndex) ? SOUND_MENU_MESSAGE_DISAPPEAR : SOUND_MENU_MESSAGE_APPEAR, gGlobalSoundSource); djui_chat_message_create(chatMsg); diff --git a/src/pc/djui/djui_chat_message.h b/src/pc/djui/djui_chat_message.h index 5eb451b48..cc79c5b00 100644 --- a/src/pc/djui/djui_chat_message.h +++ b/src/pc/djui/djui_chat_message.h @@ -2,6 +2,7 @@ #include "djui.h" #define MAX_CHAT_MSG_LENGTH 500 +#define MAX_CHAT_PACKET_LENGTH (MAX_CONFIG_STRING + MAX_CHAT_MSG_LENGTH + 19) struct DjuiChatMessage { struct DjuiBase base; diff --git a/src/pc/network/packets/packet_chat.c b/src/pc/network/packets/packet_chat.c index fc6e97423..78123c865 100644 --- a/src/pc/network/packets/packet_chat.c +++ b/src/pc/network/packets/packet_chat.c @@ -78,12 +78,12 @@ void network_send_chat(char* message, u8 globalIndex) { void network_receive_chat(struct Packet* p) { u16 remoteMessageLength = 0; - char remoteMessage[256] = { 0 }; + char remoteMessage[MAX_CHAT_MSG_LENGTH] = { 0 }; u8 globalIndex; packet_read(p, &globalIndex, sizeof(u8)); packet_read(p, &remoteMessageLength, sizeof(u16)); - if (remoteMessageLength >= 255) { remoteMessageLength = 255; } + if (remoteMessageLength >= MAX_CHAT_MSG_LENGTH - 1) { remoteMessageLength = MAX_CHAT_MSG_LENGTH - 1; } packet_read(p, &remoteMessage, remoteMessageLength * sizeof(u8)); // anti spoof