mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-24 02:30:46 +00:00
Windows: Fix potential crash in version checker.
1) see if we actually received anything (if http://eduke32.sourceforge.net/VERSION is unavailable, this returns now instead of continuing with nonsensical data) 2) check if we're getting a token from strtok() git-svn-id: https://svn.eduke32.com/eduke32@3244 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
7614a78cc5
commit
c4abfc405a
1 changed files with 16 additions and 2 deletions
|
@ -42,6 +42,7 @@ int32_t G_GetVersionFromWebsite(char *buffer)
|
|||
struct hostent *h;
|
||||
char *host = "eduke32.sourceforge.net";
|
||||
char *req = "GET http://eduke32.sourceforge.net/VERSION HTTP/1.0\r\n\r\n\r\n";
|
||||
char *tok;
|
||||
char tempbuf[2048],otherbuf[16],ver[16];
|
||||
SOCKET mysock;
|
||||
|
||||
|
@ -94,13 +95,26 @@ int32_t G_GetVersionFromWebsite(char *buffer)
|
|||
}
|
||||
|
||||
// initprintf("sent %d bytes\n",bytes_sent);
|
||||
recv(mysock, (char *)&tempbuf, sizeof(tempbuf), 0);
|
||||
i = recv(mysock, (char *)&tempbuf, sizeof(tempbuf), 0);
|
||||
if (i < 0)
|
||||
{
|
||||
// initprintf("update: recv() returned %d\n", i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
closesocket(mysock);
|
||||
|
||||
Bmemcpy(&otherbuf,&tempbuf,sizeof(otherbuf));
|
||||
|
||||
strtok(otherbuf," ");
|
||||
if (Batol(strtok(NULL," ")) == 200)
|
||||
tok = strtok(NULL," ");
|
||||
if (tok == NULL)
|
||||
{
|
||||
// initprintf("update: strtok() produced no token\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (Batol(tok) == 200)
|
||||
{
|
||||
for (i=0; (unsigned)i<strlen(tempbuf); i++) // HACK: all of this needs to die a fiery death; we just skip to the content
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue