mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +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
bb88a9150e
commit
90b52acae1
1 changed files with 18 additions and 4 deletions
|
|
@ -1320,6 +1320,8 @@ static void SV_SendServerInfo(INT32 node, tic_t servertime)
|
|||
else
|
||||
netbuffer->u.serverinfo.iszone = 0;
|
||||
|
||||
memset(netbuffer->u.serverinfo.maptitle, 0, 33);
|
||||
|
||||
if (!(mapheaderinfo[gamemap-1]->menuflags & LF2_HIDEINMENU) && mapheaderinfo[gamemap-1]->lvlttl[0])
|
||||
{
|
||||
//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
|
||||
{
|
||||
if (mapheaderinfo[gamemap-1]->actnum[0])
|
||||
snprintf(netbuffer->u.serverinfo.maptitle,
|
||||
{
|
||||
if (snprintf(netbuffer->u.serverinfo.maptitle,
|
||||
33,
|
||||
"%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
|
||||
snprintf(netbuffer->u.serverinfo.maptitle,
|
||||
{
|
||||
if (snprintf(netbuffer->u.serverinfo.maptitle,
|
||||
33,
|
||||
"%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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue