]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
prevent information leakage from trace_ globals to prvm_global client to prevent...
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 23 Sep 2009 20:55:24 +0000 (20:55 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 23 Sep 2009 20:55:24 +0000 (20:55 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9230 d7cf8633-e32d-0410-b094-e92efae38249

csprogs.c
csprogs.h
host.c

index 56b23ce7c86c3a9d635808e073425f4ec3e2cd0e..b4e62c980d40626d2349e5fb59a2daf4fe7320cf 100644 (file)
--- a/csprogs.c
+++ b/csprogs.c
 
 #define CSQC_RETURNVAL prog->globals.generic[OFS_RETURN]
 #define CSQC_BEGIN             csqc_tmpprog=prog;prog=0;PRVM_SetProg(PRVM_CLIENTPROG);
-#define CSQC_END               VM_ClearTraceGlobals(); prog=csqc_tmpprog;
-// TODO check if the clearing of trace globals takes too much CPU. If it does,
-// perform it before console command processing instead.
+#define CSQC_END               prog=csqc_tmpprog;
 
 static prvm_prog_t *csqc_tmpprog;
 
+void CL_VM_PreventInformationLeaks(void)
+{
+       prvm_eval_t *val;
+       if(!cl.csqc_loaded)
+               return;
+       CSQC_BEGIN
+               VM_ClearTraceGlobals();
+               if ((val = PRVM_GLOBALFIELDVALUE(prog->globaloffsets.trace_networkentity)))
+                       val->_float = 0;
+       CSQC_END
+}
+
 //[515]: these are required funcs
 static char *cl_required_func[] =
 {
index 7a4394c27633dc4ce73bf2064109f5d32c3a8b2b..03944584bafc83025ebd33ed8af02bc34921024f 100644 (file)
--- a/csprogs.h
+++ b/csprogs.h
@@ -53,6 +53,8 @@ extern cvar_t csqc_progname;  //[515]: csqc crc check and right csprogs name acco
 extern cvar_t csqc_progcrc;
 extern cvar_t csqc_progsize;
 
+void CL_VM_PreventInformationLeaks(void);
+
 qboolean MakeDownloadPacket(const char *filename, unsigned char *data, unsigned long len, int crc, int cnt, sizebuf_t *buf, int protocol);
 
 qboolean CL_VM_GetEntitySoundOrigin(int entnum, vec3_t out);
diff --git a/host.c b/host.c
index 76e8236b1010cfc6265efba1b1b2c20691e7360a..8e2181dfa630e3c0b9af3a41813a3f7d7379eaee 100644 (file)
--- a/host.c
+++ b/host.c
@@ -693,6 +693,7 @@ void Host_Main(void)
                if (sv.active ? sv_timer > 0 : cl_timer > 0)
                {
                        // process console commands
+                       CL_VM_PreventInformationLeaks();
                        Cbuf_Execute();
                }