From cf3fc8778934c3f2762837f18efaee4c5c6a4dce Mon Sep 17 00:00:00 2001 From: EmeraldLockdown <86802223+EmeraldLoc@users.noreply.github.com> Date: Wed, 10 Jul 2024 09:49:01 -0500 Subject: [PATCH] Fix buffer length with coopnet description (#192) * Make coopnet description length use a variable, and fix crash * move desc length define to top --- src/pc/network/coopnet/coopnet.c | 4 ++-- src/pc/network/coopnet/coopnet.h | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pc/network/coopnet/coopnet.c b/src/pc/network/coopnet/coopnet.c index 03902940..0835f728 100644 --- a/src/pc/network/coopnet/coopnet.c +++ b/src/pc/network/coopnet/coopnet.c @@ -22,7 +22,7 @@ uint64_t gCoopNetDesiredLobby = 0; char gCoopNetPassword[64] = ""; -char sCoopNetDescription[512] = ""; +char sCoopNetDescription[MAX_COOPNET_DESCRIPTION_LENGTH] = ""; static uint64_t sLocalLobbyId = 0; static uint64_t sLocalLobbyOwnerId = 0; @@ -176,7 +176,7 @@ bool ns_coopnet_is_connected(void) { static void coopnet_populate_description(void) { char* buffer = sCoopNetDescription; - int bufferLength = 1024; + int bufferLength = MAX_COOPNET_DESCRIPTION_LENGTH; // get version const char* version = get_version_online(); int versionLength = strlen(version); diff --git a/src/pc/network/coopnet/coopnet.h b/src/pc/network/coopnet/coopnet.h index ec094c7d..3a00dddd 100644 --- a/src/pc/network/coopnet/coopnet.h +++ b/src/pc/network/coopnet/coopnet.h @@ -2,6 +2,8 @@ #define COOPNET_H #ifdef COOPNET +#define MAX_COOPNET_DESCRIPTION_LENGTH 1024 + typedef void (*QueryCallbackPtr)(uint64_t aLobbyId, uint64_t aOwnerId, uint16_t aConnections, uint16_t aMaxConnections, const char* aGame, const char* aVersion, const char* aHostName, const char* aMode, const char* aDescription); typedef void (*QueryFinishCallbackPtr)(void);