Don't send random stack contents to the client with chunked downloads if the file size modulo is not 1024 or if the client requests an out of bounds block.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2411 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Mark Olsen 2006-10-15 19:31:24 +00:00
parent 3b15e738f8
commit 1a5b73909a
1 changed files with 12 additions and 4 deletions

View File

@ -1489,14 +1489,22 @@ void SV_NextChunkedDownload(int chunknum)
{
#define CHUNKSIZE 1024
char buffer[1024];
int i;
if (host_client->datagram.cursize + CHUNKSIZE+5+50 > host_client->datagram.maxsize)
return; //choked!
VFS_SEEK (host_client->download, chunknum*CHUNKSIZE);
VFS_READ (host_client->download, buffer, CHUNKSIZE);
i = VFS_READ (host_client->download, buffer, CHUNKSIZE);
MSG_WriteByte(&host_client->datagram, svc_download);
MSG_WriteLong(&host_client->datagram, chunknum);
SZ_Write(&host_client->datagram, buffer, CHUNKSIZE);
if (i > 0)
{
if (i != CHUNKSIZE)
bzero(buffer+i, CHUNKSIZE-i);
MSG_WriteByte(&host_client->datagram, svc_download);
MSG_WriteLong(&host_client->datagram, chunknum);
SZ_Write(&host_client->datagram, buffer, CHUNKSIZE);
}
}
/*