summaryrefslogtreecommitdiff
path: root/src/server/sv_client.c
diff options
context:
space:
mode:
authorTim Angus <tim@ngus.net>2006-05-16 20:50:00 +0000
committerTim Angus <tim@ngus.net>2006-05-16 20:50:00 +0000
commitbac6bec08fe63e12578c47809823cb7ee3016c44 (patch)
treed5e3b21c8d8063d2f9afc4eb71e7a7b427d91c81 /src/server/sv_client.c
parent5c0efda0ef811b2bafedb2b4f53b083a9b90e1b4 (diff)
* Merged ioq3-r783
* Added back the syscalls things I didn't mean to remove
Diffstat (limited to 'src/server/sv_client.c')
-rw-r--r--src/server/sv_client.c52
1 files changed, 45 insertions, 7 deletions
diff --git a/src/server/sv_client.c b/src/server/sv_client.c
index 3ee193dd..6cc9eecd 100644
--- a/src/server/sv_client.c
+++ b/src/server/sv_client.c
@@ -598,24 +598,60 @@ void SV_WriteDownloadToClient( client_t *cl , msg_t *msg )
int curindex;
int rate;
int blockspersnap;
- int idPack, missionPack;
+ int idPack = 0, missionPack = 0, unreferenced = 1;
char errorMessage[1024];
+ char pakbuf[MAX_QPATH], *pakptr;
+ int numRefPaks;
if (!*cl->downloadName)
return; // Nothing being downloaded
if (!cl->download) {
- // We open the file here
+ // Chop off filename extension.
+ Com_sprintf(pakbuf, sizeof(pakbuf), "%s", cl->downloadName);
+ pakptr = Q_strrchr(pakbuf, '.');
+
+ if(pakptr)
+ {
+ *pakptr = '\0';
+
+ // Check for pk3 filename extension
+ if(!Q_stricmp(pakptr + 1, "pk3"))
+ {
+ const char *referencedPaks = FS_ReferencedPakNames();
- Com_Printf( "clientDownload: %d : begining \"%s\"\n", cl - svs.clients, cl->downloadName );
+ // Check whether the file appears in the list of referenced
+ // paks to prevent downloading of arbitrary files.
+ Cmd_TokenizeStringIgnoreQuotes(referencedPaks);
+ numRefPaks = Cmd_Argc();
- missionPack = FS_idPak(cl->downloadName, "missionpack");
- idPack = missionPack || FS_idPak(cl->downloadName, BASEGAME);
+ for(curindex = 0; curindex < numRefPaks; curindex++)
+ {
+ if(!FS_FilenameCompare(Cmd_Argv(curindex), pakbuf))
+ {
+ unreferenced = 0;
+
+ // now that we know the file is referenced,
+ // check whether it's legal to download it.
+ missionPack = FS_idPak(pakbuf, "missionpack");
+ idPack = missionPack || FS_idPak(pakbuf, BASEGAME);
+
+ break;
+ }
+ }
+ }
+ }
- if ( !sv_allowDownload->integer || idPack ||
+ // We open the file here
+ if ( !sv_allowDownload->integer || idPack || unreferenced ||
( cl->downloadSize = FS_SV_FOpenFileRead( cl->downloadName, &cl->download ) ) <= 0 ) {
// cannot auto-download file
- if (idPack) {
+ if(unreferenced)
+ {
+ Com_Printf("clientDownload: %d : \"%s\" is not referenced and cannot be downloaded.\n", cl - svs.clients, cl->downloadName);
+ Com_sprintf(errorMessage, sizeof(errorMessage), "File \"%s\" is not referenced and cannot be downloaded.", cl->downloadName);
+ }
+ else if (idPack) {
Com_Printf("clientDownload: %d : \"%s\" cannot download id pk3 files\n", cl - svs.clients, cl->downloadName);
if (missionPack) {
Com_sprintf(errorMessage, sizeof(errorMessage), "Cannot autodownload Team Arena file \"%s\"\n"
@@ -651,6 +687,8 @@ void SV_WriteDownloadToClient( client_t *cl , msg_t *msg )
return;
}
+ Com_Printf( "clientDownload: %d : beginning \"%s\"\n", cl - svs.clients, cl->downloadName );
+
// Init
cl->downloadCurrentBlock = cl->downloadClientBlock = cl->downloadXmitBlock = 0;
cl->downloadCount = 0;