attempt to fix a plethora of buffer overflows when trying to connect to a server that does not exist
ex: if you typo´d the serveraddress this really aint pretty but idk how to make things not turn into limbo hell otherwise
This commit is contained in:
parent
3383778c88
commit
a54b259a3f
2 changed files with 22 additions and 0 deletions
|
|
@ -2845,6 +2845,20 @@ static void Command_connect(void)
|
|||
}
|
||||
else
|
||||
CONS_Alert(CONS_ERROR, M_GetText("There is no network driver\n"));
|
||||
|
||||
// invalid address
|
||||
if (servernode == -1)
|
||||
{
|
||||
D_QuitNetGame(); // this will also call D_CloseConnection for us
|
||||
CL_Reset();
|
||||
servernode = 0; // not sure if this is cool, but if this is -1 then bad things happen in alot of networking code
|
||||
multiplayer = false;
|
||||
netgame = false;
|
||||
|
||||
D_StartTitle();
|
||||
M_StartMessage(M_GetText("Failed to connect to server\nMake sure you put in a valid Address!\n"), NULL, MM_NOTHING);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
CV_Set(&cv_lastserver, I_GetNodeAddress(servernode));
|
||||
|
|
|
|||
|
|
@ -452,13 +452,21 @@ static const char *SOCK_GetNodeAddress(INT32 node)
|
|||
{
|
||||
if (node == 0)
|
||||
return "self";
|
||||
|
||||
if (node < 0 || node > MAXNETNODES)
|
||||
return NULL;
|
||||
|
||||
if (!nodeconnected[node])
|
||||
return NULL;
|
||||
|
||||
return SOCK_AddrToStr(&clientaddress[node]);
|
||||
}
|
||||
|
||||
static UINT32 SOCK_GetNodeAddressInt(INT32 node)
|
||||
{
|
||||
if (node < 0 || node > MAXNETNODES)
|
||||
return 0;
|
||||
|
||||
if (nodeconnected[node] && clientaddress[node].any.sa_family == AF_INET)
|
||||
{
|
||||
return clientaddress[node].ip4.sin_addr.s_addr;
|
||||
|
|
|
|||
Loading…
Reference in a new issue