mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2025-02-04 07:21:01 +00:00
Fix potential warning from string truncation
Also the MS seems to just throw the entire char array into the website and ignore null terminators, so I'm memsetting maptitle all to 0 before we do anything with it.
This commit is contained in:
parent
0e3b225011
commit
5a96a0d0a4
1 changed files with 18 additions and 4 deletions
|
@ -1320,6 +1320,8 @@ static void SV_SendServerInfo(INT32 node, tic_t servertime)
|
||||||
else
|
else
|
||||||
netbuffer->u.serverinfo.iszone = 0;
|
netbuffer->u.serverinfo.iszone = 0;
|
||||||
|
|
||||||
|
memset(netbuffer->u.serverinfo.maptitle, 0, 33);
|
||||||
|
|
||||||
if (!(mapheaderinfo[gamemap-1]->menuflags & LF2_HIDEINMENU) && mapheaderinfo[gamemap-1]->lvlttl[0])
|
if (!(mapheaderinfo[gamemap-1]->menuflags & LF2_HIDEINMENU) && mapheaderinfo[gamemap-1]->lvlttl[0])
|
||||||
{
|
{
|
||||||
//strncpy(netbuffer->u.serverinfo.maptitle, (char *)mapheaderinfo[gamemap-1]->lvlttl, 33);
|
//strncpy(netbuffer->u.serverinfo.maptitle, (char *)mapheaderinfo[gamemap-1]->lvlttl, 33);
|
||||||
|
@ -1340,15 +1342,27 @@ static void SV_SendServerInfo(INT32 node, tic_t servertime)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (mapheaderinfo[gamemap-1]->actnum[0])
|
if (mapheaderinfo[gamemap-1]->actnum[0])
|
||||||
snprintf(netbuffer->u.serverinfo.maptitle,
|
{
|
||||||
|
if (snprintf(netbuffer->u.serverinfo.maptitle,
|
||||||
33,
|
33,
|
||||||
"%s %s %s",
|
"%s %s %s",
|
||||||
mapheaderinfo[gamemap-1]->lvlttl, mapheaderinfo[gamemap-1]->zonttl, mapheaderinfo[gamemap-1]->actnum);
|
mapheaderinfo[gamemap-1]->lvlttl, mapheaderinfo[gamemap-1]->zonttl, mapheaderinfo[gamemap-1]->actnum) < 0)
|
||||||
|
{
|
||||||
|
// If there's an encoding error, send UNKNOWN, we accept that the above may be truncated
|
||||||
|
strncpy(netbuffer->u.serverinfo.maptitle, "UNKNOWN", 33);
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
snprintf(netbuffer->u.serverinfo.maptitle,
|
{
|
||||||
|
if (snprintf(netbuffer->u.serverinfo.maptitle,
|
||||||
33,
|
33,
|
||||||
"%s %s",
|
"%s %s",
|
||||||
mapheaderinfo[gamemap-1]->lvlttl, mapheaderinfo[gamemap-1]->zonttl);
|
mapheaderinfo[gamemap-1]->lvlttl, mapheaderinfo[gamemap-1]->zonttl) < 0)
|
||||||
|
{
|
||||||
|
// If there's an encoding error, send UNKNOWN, we accept that the above may be truncated
|
||||||
|
strncpy(netbuffer->u.serverinfo.maptitle, "UNKNOWN", 33);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue