Bugfix: NUL terminate the MOTD string buffer
If registering with the lobby server failed once, we don't want part of the failure message to be kept at the end of the MOTD string. git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7270 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
7e7ba74801
commit
47bbacc7bb
|
@ -1830,12 +1830,14 @@ static void NETregisterServer(int state)
|
|||
}
|
||||
if (SDLNet_SocketReady(rs_socket)) // true on activity
|
||||
{
|
||||
result = SDLNet_TCP_Recv(rs_socket, NetPlay.MOTDbuffer, sizeof(NetPlay.MOTDbuffer));
|
||||
result = SDLNet_TCP_Recv(rs_socket, NetPlay.MOTDbuffer, sizeof(NetPlay.MOTDbuffer) - 1);
|
||||
if (result <= 0)
|
||||
{
|
||||
debug(LOG_NET, "Warning, MOTD TCP_Recv failed. result = %d, error %s", result, SDLNet_GetError());
|
||||
sstrcpy(NetPlay.MOTDbuffer, "MOTD communication error with lobby server, TCP_Recv failed!");
|
||||
}
|
||||
// Make sure to NUL terminate the MOTD string
|
||||
NetPlay.MOTDbuffer[result] = '\0';
|
||||
debug(LOG_NET, "MOTD is [%s]", NetPlay.MOTDbuffer);
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue