Fix buffer length with coopnet description (#192)

* Make coopnet description length use a variable, and fix crash

* move desc length define to top
This commit is contained in:
EmeraldLockdown 2024-07-10 09:49:01 -05:00 committed by GitHub
parent c0c2352617
commit cf3fc87789
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 2 deletions

View file

@ -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);

View file

@ -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);