Fix server description infinite loop and raise max length

This commit is contained in:
NepDisk 2025-10-20 19:08:50 -04:00
parent 7723e414e4
commit 1a33deff34
3 changed files with 13 additions and 8 deletions

View file

@ -42,9 +42,9 @@ applications may follow different packet versions.
// be transmitted.
#define MAXSERVERNAME 32
#define MAXSERVERCONTACT 320
#define MAXSERVERDESCRIPTION 320
#define MAXSERVERDESCRIPTIONLINE 40
#define MAXSERVERCONTACT 350
#define MAXSERVERDESCRIPTION 1024
#define MAXSERVERDESCRIPTIONLINE 80
#define DEFAULTDESCSTRING "Welcome to my SRB2Kart server!\n"
// Sends over info via packets to client players.

View file

@ -112,7 +112,7 @@ demoghost *ghosts = NULL;
// DEMO RECORDING
//
#define DEMOVERSION 0x000C
#define DEMOVERSION 0x000D
#define DEMOHEADER "\xF0" "BlanReplay" "\x0F"
#define DF_GHOST 0x01 // This demo contains ghost data too!
@ -657,6 +657,7 @@ static headerstatus_e G_ReadDemoHeader(UINT8 *dp, demoheader_t *header)
boolean kart = false, oldkart = false;
boolean raflag = true;
boolean serverinfo = true;
boolean oldserverinfolength = false;
// these may not be present in old demo formats, so initialize them
// also initialize them so the header can be free'd without issues
@ -683,9 +684,10 @@ static headerstatus_e G_ReadDemoHeader(UINT8 *dp, demoheader_t *header)
case DEMOVERSION: // latest always supported
break;
case 0x000C:
case 0x000B:
break;
case 0x000A:
oldserverinfolength = true;
break;
case 0x0009:
@ -755,9 +757,12 @@ static headerstatus_e G_ReadDemoHeader(UINT8 *dp, demoheader_t *header)
if (serverinfo)
{
size_t maxservercontact = oldserverinfolength ? 320 : MAXSERVERCONTACT;
size_t maxdescription = oldserverinfolength ? 320 : MAXSERVERDESCRIPTION;
READSTRINGN(dp, header->servername, MAXSERVERNAME);
READSTRINGN(dp, header->servercontact, MAXSERVERCONTACT);
READSTRINGN(dp, header->serverdescription, MAXSERVERDESCRIPTION);
READSTRINGN(dp, header->servercontact, maxservercontact);
READSTRINGN(dp, header->serverdescription, maxdescription);
}
if (oldkart)

View file

@ -2528,7 +2528,7 @@ static void K_DrawServerMods(INT32 x, INT32 y)
void K_DrawServerDescrption(INT32 x, INT32 y)
{
UINT8 i, newlinecount = 0;
INT32 i, newlinecount = 0;
if (connectedservername[0] != '\0')
V_DrawThinString(x, y, V_6WIDTHSPACE|V_ALLOWLOWERCASE, connectedservername);