From ddf8a189dbd460a6520f5edd24a6cdb8d3760abb Mon Sep 17 00:00:00 2001 From: Lactozilla <jp6781615@gmail.com> Date: Sat, 17 Feb 2024 15:41:39 -0300 Subject: [PATCH] Increase size of mapname in serverinfo_pak --- src/netcode/protocol.h | 4 ++-- src/netcode/server_connection.c | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/netcode/protocol.h b/src/netcode/protocol.h index 4b39fab664..058254a908 100644 --- a/src/netcode/protocol.h +++ b/src/netcode/protocol.h @@ -26,7 +26,7 @@ packet versions. If you change the struct or the meaning of a field therein, increment this number. */ -#define PACKETVERSION 5 +#define PACKETVERSION 6 // Network play related stuff. // There is a data struct that stores network @@ -226,7 +226,7 @@ typedef struct tic_t time; tic_t leveltime; char servername[MAXSERVERNAME]; - char mapname[8]; + char mapname[24]; char maptitle[33]; unsigned char mapmd5[16]; UINT8 actnum; diff --git a/src/netcode/server_connection.c b/src/netcode/server_connection.c index ef7f7e519a..616bdbfbaf 100644 --- a/src/netcode/server_connection.c +++ b/src/netcode/server_connection.c @@ -114,15 +114,15 @@ static void SV_SendServerInfo(INT32 node, tic_t servertime) netbuffer->u.serverinfo.refusereason = GetRefuseReason(node); - strncpy(netbuffer->u.serverinfo.gametypename, Gametype_Names[gametype], + strlcpy(netbuffer->u.serverinfo.gametypename, Gametype_Names[gametype], sizeof netbuffer->u.serverinfo.gametypename); netbuffer->u.serverinfo.modifiedgame = (UINT8)modifiedgame; netbuffer->u.serverinfo.cheatsenabled = CV_CheatsEnabled(); netbuffer->u.serverinfo.flags = (dedicated ? SV_DEDICATED : 0); - strncpy(netbuffer->u.serverinfo.servername, cv_servername.string, + strlcpy(netbuffer->u.serverinfo.servername, cv_servername.string, MAXSERVERNAME); - strncpy(netbuffer->u.serverinfo.mapname, G_BuildMapName(gamemap), 7); // [mapnames] FIXME + strlcpy(netbuffer->u.serverinfo.mapname, G_BuildMapName(gamemap), sizeof netbuffer->u.serverinfo.mapname); M_Memcpy(netbuffer->u.serverinfo.mapmd5, mapmd5, 16); memset(netbuffer->u.serverinfo.maptitle, 0, sizeof netbuffer->u.serverinfo.maptitle); @@ -142,7 +142,6 @@ static void SV_SendServerInfo(INT32 node, tic_t servertime) read++; } *writ = '\0'; - //strncpy(netbuffer->u.serverinfo.maptitle, (char *)mapheaderinfo[gamemap-1]->lvlttl, 33); } else strncpy(netbuffer->u.serverinfo.maptitle, "UNKNOWN", 32); -- GitLab