diff options
author | Tim Angus <tim@ngus.net> | 2006-05-16 20:50:00 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2006-05-16 20:50:00 +0000 |
commit | bac6bec08fe63e12578c47809823cb7ee3016c44 (patch) | |
tree | d5e3b21c8d8063d2f9afc4eb71e7a7b427d91c81 | |
parent | 5c0efda0ef811b2bafedb2b4f53b083a9b90e1b4 (diff) |
* Merged ioq3-r783
* Added back the syscalls things I didn't mean to remove
-rw-r--r-- | src/client/qal.h | 10 | ||||
-rw-r--r-- | src/game/g_syscalls.asm | 13 | ||||
-rw-r--r-- | src/qcommon/files.c | 9 | ||||
-rw-r--r-- | src/qcommon/vm_x86.c | 18 | ||||
-rw-r--r-- | src/server/sv_client.c | 52 |
5 files changed, 85 insertions, 17 deletions
diff --git a/src/client/qal.h b/src/client/qal.h index 8592c081..7747d987 100644 --- a/src/client/qal.h +++ b/src/client/qal.h @@ -38,8 +38,14 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "../AL/al.h" #include "../AL/alc.h" #else -#include <AL/al.h> -#include <AL/alc.h> +#ifdef _MSC_VER + // MSVC users must install the OpenAL SDK which doesn't use the AL/*.h scheme. + #include <al.h> + #include <alc.h> +#else + #include <AL/al.h> + #include <AL/alc.h> +#endif #endif #if USE_OPENAL_DLOPEN diff --git a/src/game/g_syscalls.asm b/src/game/g_syscalls.asm index 79a9b3d6..e77017b7 100644 --- a/src/game/g_syscalls.asm +++ b/src/game/g_syscalls.asm @@ -50,3 +50,16 @@ equ trap_Parse_ReadToken -46 equ trap_Parse_SourceFileAndLine -47 equ trap_SendGameStat -48 + + +equ memset -101 +equ memcpy -102 +equ strncpy -103 +equ sin -104 +equ cos -105 +equ atan2 -106 +equ sqrt -107 +equ floor -111 +equ ceil -112 +equ testPrintInt -113 +equ testPrintFloat -114 diff --git a/src/qcommon/files.c b/src/qcommon/files.c index ce380438..c5b46607 100644 --- a/src/qcommon/files.c +++ b/src/qcommon/files.c @@ -2550,16 +2550,9 @@ FS_idPak */ qboolean FS_idPak( char *pak, char *base ) { int i; - char pakbuf[MAX_QPATH], *pakptr; - - // Chop off filename extension if necessary. - Com_sprintf(pakbuf, sizeof(pakbuf), "%s", pak); - pakptr = Q_strrchr(pakbuf, '.'); - if(pakptr) - *pakptr = '\0'; for (i = 0; i < NUM_ID_PAKS; i++) { - if ( !FS_FilenameCompare(pakbuf, va("%s/pak%d", base, i)) ) { + if ( !FS_FilenameCompare(pak, va("%s/pak%d", base, i)) ) { break; } } diff --git a/src/qcommon/vm_x86.c b/src/qcommon/vm_x86.c index 2115cf50..c0a703bc 100644 --- a/src/qcommon/vm_x86.c +++ b/src/qcommon/vm_x86.c @@ -23,6 +23,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // vm_x86.c -- load time compiler and execution environment for x86 #include "vm_local.h" +#ifdef _WIN32 +#include <windows.h> +#endif #ifdef __FreeBSD__ // rb0101023 #include <sys/types.h> @@ -1082,6 +1085,11 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) { vm->codeBase = mmap(NULL, compiledOfs, PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS, -1, 0); if(vm->codeBase == (void*)-1) Com_Error(ERR_DROP, "VM_CompileX86: can't mmap memory"); +#elif _WIN32 + // allocate memory with EXECUTE permissions under windows. + vm->codeBase = VirtualAlloc(NULL, compiledOfs, MEM_COMMIT, PAGE_EXECUTE_READWRITE); + if(!vm->codeBase) + Com_Error(ERR_DROP, "VM_CompileX86: VirtualAlloc failed"); #else vm->codeBase = malloc(compiledOfs); #endif @@ -1091,6 +1099,14 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) { #ifdef VM_X86_MMAP if(mprotect(vm->codeBase, compiledOfs, PROT_READ|PROT_EXEC)) Com_Error(ERR_DROP, "VM_CompileX86: mprotect failed"); +#elif _WIN32 + { + DWORD oldProtect = 0; + + // remove write permissions. + if(!VirtualProtect(vm->codeBase, compiledOfs, PAGE_EXECUTE_READ, &oldProtect)) + Com_Error(ERR_DROP, "VM_CompileX86: VirtualProtect failed"); + } #endif Z_Free( buf ); @@ -1109,6 +1125,8 @@ void VM_Destroy_Compiled(vm_t* self) { #ifdef VM_X86_MMAP munmap(self->codeBase, self->codeLength); +#elif _WIN32 + VirtualFree(self->codeBase, self->codeLength, MEM_RELEASE); #else free(self->codeBase); #endif 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; |