summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrey Nazarov <skuller@skuller.net>2011-04-04 14:10:51 +0400
committerAndrey Nazarov <skuller@skuller.net>2011-04-07 14:23:30 +0400
commitf071b8eb6c993f608c1361fba3fc9a7262289afc (patch)
tree0318cea66b9ab07835faba1c271509228de388f2 /src
parent9b8ed7c2035d622dd10153848c3b4ed9d32c50d7 (diff)
Allow downloads to be disabled permanently.
Setting ‘allow_download’ variable to -1 will force the client to disable downloads until it is restarted. This can be used as a protection measure from malicious (or just stupid) servers that force downloads by stuffing commands.
Diffstat (limited to 'src')
-rw-r--r--src/cl_download.c7
-rw-r--r--src/cl_http.c4
-rw-r--r--src/cl_main.c12
3 files changed, 22 insertions, 1 deletions
diff --git a/src/cl_download.c b/src/cl_download.c
index 9c36304..6562030 100644
--- a/src/cl_download.c
+++ b/src/cl_download.c
@@ -517,7 +517,7 @@ void CL_RequestNextDownload( void ) {
if( cls.state != ca_connected && cls.state != ca_loading )
return;
- if( !allow_download->integer || NET_IsLocalAddress( &cls.serverAddress ) ) {
+ if( allow_download->integer <= 0 || NET_IsLocalAddress( &cls.serverAddress ) ) {
if( precache_check <= PRECACHE_MAP ) {
CL_RegisterModels();
}
@@ -697,6 +697,11 @@ static void CL_Download_f( void ) {
return;
}
+ if( allow_download->integer == -1 ) {
+ Com_Printf( "Downloads are permanently disabled.\n" );
+ return;
+ }
+
if( Cmd_Argc() != 2 ) {
Com_Printf( "Usage: download <filename>\n" );
return;
diff --git a/src/cl_http.c b/src/cl_http.c
index 6635024..3ee3ac8 100644
--- a/src/cl_http.c
+++ b/src/cl_http.c
@@ -400,6 +400,10 @@ void HTTP_SetServer (const char *url) {
if (!*url)
return;
+ // ignore if downloads are permanently disabled
+ if (allow_download->integer == -1)
+ return;
+
if (strncmp (url, "http://", 7)) {
Com_Printf ("[HTTP] Ignoring download server URL with non-HTTP schema.\n");
return;
diff --git a/src/cl_main.c b/src/cl_main.c
index 4a8adc8..e3accd5 100644
--- a/src/cl_main.c
+++ b/src/cl_main.c
@@ -2501,6 +2501,15 @@ static void cl_sync_changed( cvar_t *self ) {
CL_UpdateFrameTimes();
}
+// allow downloads to be permanently disabled as a
+// protection measure from malicious (or just stupid) servers
+// that force downloads by stuffing commands
+static void cl_allow_download_changed( cvar_t *self ) {
+ if( self->integer == -1 ) {
+ self->flags |= CVAR_ROM;
+ }
+}
+
static const cmdreg_t c_client[] = {
{ "cmd", CL_ForwardToServer_f },
{ "pause", CL_Pause_f },
@@ -2644,6 +2653,9 @@ static void CL_InitLocal ( void ) {
cl_vwep = Cvar_Get ( "cl_vwep", "1", CVAR_ARCHIVE );
cl_vwep->changed = cl_vwep_changed;
+ allow_download->changed = cl_allow_download_changed;
+ cl_allow_download_changed( allow_download );
+
//
// userinfo
//