diff --git a/games/openarena/Makefile b/games/openarena/Makefile index 7f9df40627ac..de89ec151de5 100644 --- a/games/openarena/Makefile +++ b/games/openarena/Makefile @@ -1,45 +1,46 @@ PORTNAME= openarena PORTVERSION= ${GAMEVERSION}.s${SVNREVISION} +PORTREVISION= 1 PORTEPOCH= 2 MASTER_SITES= SF/oarena/src \ http://files.poulsander.com/~poul19/public_files/oa/dev088/ DISTNAME= ${PORTNAME}-engine-source-${GAMEVERSION} EXTRACT_SUFX= .tar.bz2 # override master port MAINTAINER= ports@FreeBSD.org COMMENT= Quake3 total conversion based on the ioquake3 engine WWW= http://openarena.ws/ LICENSE?= GPLv2 RUN_DEPENDS= ${LOCALBASE}/${DATADIR_REL}/${Q3BASE}/pak0.pk3:games/openarena-data USES= tar:bzip2 MASTERDIR= ${.CURDIR}/../ioquake3 DESCR= ${.CURDIR}/../${PORTNAME}/pkg-descr DISTINFO_FILE= ${.CURDIR}/../${PORTNAME}/distinfo PATCHDIR= ${.CURDIR}/../${PORTNAME}/files PKGMESSAGE= ${.CURDIR}/../${PORTNAME}/pkg-message IOQ3?= CLIENT IOQ3ARCH?= ${ARCH} IOQ3SDL= sdl # OpenArena doc is too messy to bother OPTIONS_EXCLUDE= DOCS GAMEVERSION= 0.8.8 SVNREVISION= 1910 Q3ENGINEVER= SVN${SVNREVISION}+${GAMEVERSION} Q3TOTALCONV= yes Q3CLIENT= openarena Q3SERVER= oa_ded Q3BASE= baseoa Q3DIR= ${DATADIR} # No icon included with OpenArena Q3ICON= pre-patch: @${FIND} ${WRKSRC} -name \*.orig -delete .include "${MASTERDIR}/Makefile" diff --git a/games/openarena/files/patch-code_client_snd__openal.c b/games/openarena/files/patch-code_client_snd__openal.c index 136e269b1de7..930229586f23 100644 --- a/games/openarena/files/patch-code_client_snd__openal.c +++ b/games/openarena/files/patch-code_client_snd__openal.c @@ -1,24 +1,24 @@ --- code/client/snd_openal.c.orig 2011-12-24 12:29:31 UTC +++ code/client/snd_openal.c @@ -2072,7 +2072,7 @@ static cvar_t *s_alCapture; #elif defined(MACOS_X) #define ALDRIVER_DEFAULT "/System/Library/Frameworks/OpenAL.framework/OpenAL" #else -#define ALDRIVER_DEFAULT "libopenal.so.1" +#define ALDRIVER_DEFAULT "libopenal.so" #endif /* -@@ -2358,6 +2358,12 @@ qboolean S_AL_Init( soundInterface_t *si +@@ -2357,6 +2357,12 @@ qboolean S_AL_Init( soundInterface_t *si ) + s_alDriver = Cvar_Get( "s_alDriver", ALDRIVER_DEFAULT, CVAR_ARCHIVE | CVAR_LATCH ); s_alDevice = Cvar_Get("s_alDevice", "", CVAR_ARCHIVE | CVAR_LATCH); - ++ + if ( COM_CompareExtension( s_alDriver->string, ".pk3" ) ) + { + Com_Printf( S_COLOR_RED "Rejecting s_alDriver named \"%s\"\n", s_alDriver->string ); + return qfalse; + } -+ + // Load QAL if( !QAL_Init( s_alDriver->string ) ) - { diff --git a/games/openarena/files/patch-code_qcommon_files.c b/games/openarena/files/patch-code_qcommon_files.c index b35962d7c3e1..e1cebd665482 100644 --- a/games/openarena/files/patch-code_qcommon_files.c +++ b/games/openarena/files/patch-code_qcommon_files.c @@ -1,284 +1,282 @@ --- code/qcommon/files.c.orig 2011-12-24 12:29:32 UTC +++ code/qcommon/files.c -@@ -195,6 +195,9 @@ static const unsigned int missionpak_che +@@ -195,6 +195,9 @@ static const unsigned int missionpak_checksums[] = 1438664554u }; +int dangerousPaksFound; +char dangerousPakNames[MAX_ZPATH][MAX_SEARCH_PATHS]; + // if this is defined, the executable positively won't work with any paks other // than the demo pak, even if productid is present. This is only used for our // last demo release to prevent the mac and linux users from using the demo -@@ -250,6 +253,7 @@ static cvar_t *fs_apppath; +@@ -250,6 +253,7 @@ static cvar_t *fs_basepath; #endif static cvar_t *fs_basepath; +static cvar_t *fs_libpath; static cvar_t *fs_basegame; static cvar_t *fs_gamedirvar; static searchpath_t *fs_searchpaths; @@ -529,30 +533,32 @@ qboolean FS_CreatePath (char *OSPath) { /* ================= -FS_CheckFilenameIsNotExecutable +FS_CheckFilenameIsMutable -ERR_FATAL if trying to maniuplate a file with the platform library extension +ERR_FATAL if trying to maniuplate a file with the platform library, QVM, or pk3 extension ================= */ -static void FS_CheckFilenameIsNotExecutable( const char *filename, +static void FS_CheckFilenameIsMutable( const char *filename, const char *function ) { - // Check if the filename ends with the library extension - if( !Q_stricmp( COM_GetExtension( filename ), DLL_EXT ) ) + // Check if the filename ends with the library, QVM, or pk3 extension + if( COM_CompareExtension( filename, DLL_EXT ) + || COM_CompareExtension( filename, ".qvm" ) + || COM_CompareExtension( filename, ".pk3" ) ) { Com_Error( ERR_FATAL, "%s: Not allowed to manipulate '%s' due " - "to %s extension\n", function, filename, DLL_EXT ); + "to %s extension", function, filename, COM_GetExtension( filename ) ); } } /* -=========== +================= FS_Remove =========== */ void FS_Remove( const char *osPath ) { - FS_CheckFilenameIsNotExecutable( osPath, __func__ ); + FS_CheckFilenameIsMutable( osPath, __func__ ); remove( osPath ); } -@@ -564,7 +570,7 @@ FS_HomeRemove +@@ -564,7 +570,7 @@ void FS_HomeRemove( const char *homePath ) { =========== */ void FS_HomeRemove( const char *homePath ) { - FS_CheckFilenameIsNotExecutable( homePath, __func__ ); + FS_CheckFilenameIsMutable( homePath, __func__ ); remove( FS_BuildOSPath( fs_homepath->string, fs_gamedir, homePath ) ); -@@ -643,7 +649,7 @@ fileHandle_t FS_SV_FOpenFileWrite( const +@@ -643,7 +649,7 @@ fileHandle_t FS_SV_FOpenFileWrite( const char *filenam Com_Printf( "FS_SV_FOpenFileWrite: %s\n", ospath ); } - FS_CheckFilenameIsNotExecutable( ospath, __func__ ); + FS_CheckFilenameIsMutable( ospath, __func__ ); if( FS_CreatePath( ospath ) ) { return 0; @@ -735,7 +741,7 @@ FS_SV_Rename =========== */ -void FS_SV_Rename( const char *from, const char *to ) { +void FS_SV_Rename( const char *from, const char *to, qboolean safe ) { char *from_ospath, *to_ospath; if ( !fs_searchpaths ) { -@@ -754,7 +760,11 @@ void FS_SV_Rename( const char *from, con +@@ -754,7 +760,9 @@ void FS_SV_Rename( const char *from, const char *to ) Com_Printf( "FS_SV_Rename: %s --> %s\n", from_ospath, to_ospath ); } - FS_CheckFilenameIsNotExecutable( to_ospath, __func__ ); -+ FS_CheckFilenameIsMutable( to_ospath, __func__ ); -+ + if ( safe ) { + FS_CheckFilenameIsMutable( to_ospath, __func__ ); + } rename(from_ospath, to_ospath); } -@@ -784,7 +794,7 @@ void FS_Rename( const char *from, const +@@ -784,7 +792,7 @@ void FS_Rename( const char *from, const char *to ) { Com_Printf( "FS_Rename: %s --> %s\n", from_ospath, to_ospath ); } - FS_CheckFilenameIsNotExecutable( to_ospath, __func__ ); + FS_CheckFilenameIsMutable( to_ospath, __func__ ); rename(from_ospath, to_ospath); } -@@ -843,7 +853,7 @@ fileHandle_t FS_FOpenFileWrite( const ch +@@ -843,7 +851,7 @@ fileHandle_t FS_FOpenFileWrite( const char *filename ) Com_Printf( "FS_FOpenFileWrite: %s\n", ospath ); } - FS_CheckFilenameIsNotExecutable( ospath, __func__ ); + FS_CheckFilenameIsMutable( ospath, __func__ ); if( FS_CreatePath( ospath ) ) { return 0; -@@ -891,7 +901,7 @@ fileHandle_t FS_FOpenFileAppend( const c +@@ -891,7 +899,7 @@ fileHandle_t FS_FOpenFileAppend( const char *filename Com_Printf( "FS_FOpenFileAppend: %s\n", ospath ); } - FS_CheckFilenameIsNotExecutable( ospath, __func__ ); + FS_CheckFilenameIsMutable( ospath, __func__ ); if( FS_CreatePath( ospath ) ) { return 0; -@@ -963,6 +973,7 @@ int FS_FOpenFileRead( const char *filena +@@ -963,6 +971,7 @@ int FS_FOpenFileRead( const char *filename, fileHandle FILE *temp; int l; char demoExt[16]; + qboolean isLocalConfig, isQVM; hash = 0; -@@ -970,11 +981,22 @@ int FS_FOpenFileRead( const char *filena +@@ -970,11 +979,22 @@ int FS_FOpenFileRead( const char *filename, fileHandle Com_Error( ERR_FATAL, "Filesystem call made without initialization\n" ); } + isLocalConfig = !Q_stricmp(filename, "autoexec.cfg") || !Q_stricmp(filename, "q3config.cfg"); + isQVM = COM_CompareExtension(filename, ".qvm"); + if ( file == NULL ) { // just wants to see if file is there for ( search = fs_searchpaths ; search ; search = search->next ) { // if ( search->pack ) { + // autoexec.cfg and q3config.cfg can only be loaded outside of pk3 files. + if (isLocalConfig) + continue; + + // QVMs can't be loaded from pk3 in the "download" directory + if (isQVM && !Q_stricmp(search->pack->pakGamename, "download")) + continue; + hash = FS_HashFileName(filename, search->pack->hashSize); } // is the element a pak file? -@@ -1040,6 +1062,14 @@ int FS_FOpenFileRead( const char *filena +@@ -1040,6 +1060,14 @@ int FS_FOpenFileRead( const char *filename, fileHandle for ( search = fs_searchpaths ; search ; search = search->next ) { // if ( search->pack ) { + // autoexec.cfg and q3config.cfg can only be loaded outside of pk3 files. + if (isLocalConfig) + continue; + + // QVMs can't be loaded from pk3 in the "download" directory + if (isQVM && !Q_stricmp(search->pack->pakGamename, "download")) + continue; + hash = FS_HashFileName(filename, search->pack->hashSize); } // is the element a pak file? -@@ -1657,7 +1687,7 @@ Creates a new pak_t in the search chain +@@ -1657,7 +1685,7 @@ of a zip file. of a zip file. ================= */ -static pack_t *FS_LoadZipFile(const char *zipfile, const char *basename) +static pack_t *FS_LoadZipFile(const char *zipfile, const char *basename, const char *gamename ) { fileInPack_t *buildBuffer; pack_t *pack; -@@ -1666,11 +1696,12 @@ static pack_t *FS_LoadZipFile(const char +@@ -1666,11 +1694,12 @@ static pack_t *FS_LoadZipFile(const char *zipfile, con unz_global_info gi; char filename_inzip[MAX_ZPATH]; unz_file_info file_info; - int i, len; + int i, j, len; long hash; int fs_numHeaderLongs; int *fs_headerLongs; char *namePtr; + qboolean alreadydangerous = qfalse; fs_numHeaderLongs = 0; -@@ -1714,6 +1745,7 @@ static pack_t *FS_LoadZipFile(const char +@@ -1714,6 +1743,7 @@ static pack_t *FS_LoadZipFile(const char *zipfile, con Q_strncpyz( pack->pakFilename, zipfile, sizeof( pack->pakFilename ) ); Q_strncpyz( pack->pakBasename, basename, sizeof( pack->pakBasename ) ); + Q_strncpyz( pack->pakGamename, gamename, sizeof( pack->pakGamename ) ); // strip .pk3 if needed if ( strlen( pack->pakBasename ) > 4 && !Q_stricmp( pack->pakBasename + strlen( pack->pakBasename ) - 4, ".pk3" ) ) { -@@ -1730,6 +1762,30 @@ static pack_t *FS_LoadZipFile(const char +@@ -1730,6 +1760,30 @@ static pack_t *FS_LoadZipFile(const char *zipfile, con if (err != UNZ_OK) { break; } + + if (!Q_stricmp(pack->pakGamename, "download") && ( + COM_CompareExtension(filename_inzip, ".qvm") || + !Q_stricmp(filename_inzip, "autoexec.cfg") || + !Q_stricmp(filename_inzip, "q3config.cfg"))) + { + + for (j = 0; j < dangerousPaksFound; j++) { + if (!strcmp(dangerousPakNames[j], pack->pakBasename)) { + alreadydangerous = qtrue; + break; + } + } + + if (!alreadydangerous) { + Q_strncpyz(dangerousPakNames[dangerousPaksFound], pack->pakBasename, MAX_ZPATH); + dangerousPaksFound++; + } + + Com_Printf(S_COLOR_RED "Dangerous file %s found in %s\n", + filename_inzip, + pack->pakFilename); + } + if (file_info.uncompressed_size > 0) { fs_headerLongs[fs_numHeaderLongs++] = LittleLong(file_info.crc); } -@@ -1784,7 +1840,7 @@ qboolean FS_CompareZipChecksum(const cha +@@ -1784,7 +1838,7 @@ qboolean FS_CompareZipChecksum(const char *zipfile) pack_t *thepak; int index, checksum; - thepak = FS_LoadZipFile(zipfile, ""); + thepak = FS_LoadZipFile(zipfile, "", ""); if(!thepak) return qfalse; -@@ -2569,10 +2625,8 @@ void FS_AddGameDirectory( const char *pa +@@ -2569,10 +2623,8 @@ void FS_AddGameDirectory( const char *path, const char for ( i = 0 ; i < numfiles ; i++ ) { pakfile = FS_BuildOSPath( path, dir, pakfiles[i] ); - if ( ( pak = FS_LoadZipFile( pakfile, pakfiles[i] ) ) == 0 ) + if ( ( pak = FS_LoadZipFile( pakfile, pakfiles[i], dir ) ) == 0 ) continue; - // store the game name for downloading - strcpy(pak->pakGamename, dir); fs_packFiles += pak->numfiles; -@@ -2854,11 +2908,14 @@ static void FS_Startup( const char *game +@@ -2854,11 +2906,14 @@ static void FS_Startup( const char *gameName ) Com_Printf( "----- FS_Startup -----\n" ); + dangerousPaksFound = 0; + fs_packFiles = 0; fs_debug = Cvar_Get( "fs_debug", "0", 0 ); fs_basepath = Cvar_Get ("fs_basepath", Sys_DefaultInstallPath(), CVAR_INIT ); fs_basegame = Cvar_Get ("fs_basegame", "", CVAR_INIT ); + fs_libpath = Cvar_Get ("fs_libpath", Sys_DefaultLibPath(), CVAR_INIT ); homePath = Sys_DefaultHomePath(); if (!homePath || !homePath[0]) { homePath = fs_basepath->string; -@@ -2878,6 +2935,11 @@ static void FS_Startup( const char *game +@@ -2878,6 +2933,11 @@ static void FS_Startup( const char *gameName ) if (fs_apppath->string[0]) FS_AddGameDirectory(fs_apppath->string, gameName); #endif + + // Search default library location if given + if (fs_libpath->string[0]) { + FS_AddGameDirectory ( fs_libpath->string, gameName ); + } // NOTE: same filtering below for mods and basegame if (fs_homepath->string[0] && Q_stricmp(fs_homepath->string,fs_basepath->string)) { diff --git a/games/openarena/files/patch-code_qcommon_qcommon.h b/games/openarena/files/patch-code_qcommon_qcommon.h index 80bca4095d6a..56b32faea469 100644 --- a/games/openarena/files/patch-code_qcommon_qcommon.h +++ b/games/openarena/files/patch-code_qcommon_qcommon.h @@ -1,34 +1,34 @@ --- code/qcommon/qcommon.h.orig 2011-12-24 12:29:32 UTC +++ code/qcommon/qcommon.h @@ -571,6 +571,12 @@ issues. ============================================================== */ +#define MAX_ZPATH 256 +#define MAX_SEARCH_PATHS 4096 + +extern int dangerousPaksFound; +extern char dangerousPakNames[MAX_ZPATH][MAX_SEARCH_PATHS]; + // referenced flags // these are in loop specific order so don't change the order #define FS_GENERAL_REF 0x01 -@@ -627,7 +633,7 @@ fileHandle_t FS_FOpenFileAppend( const c +@@ -627,7 +633,7 @@ int FS_SV_FOpenFileRead( const char *filename, fileHa fileHandle_t FS_SV_FOpenFileWrite( const char *filename ); int FS_SV_FOpenFileRead( const char *filename, fileHandle_t *fp ); -void FS_SV_Rename( const char *from, const char *to ); +void FS_SV_Rename( const char *from, const char *to, qboolean safe ); int FS_FOpenFileRead( const char *qpath, fileHandle_t *file, qboolean uniqueFILE ); // if uniqueFILE is true, then a new FILE will be fopened even if the file // is found in an already open pak file. If uniqueFILE is false, you must call -@@ -1099,6 +1105,9 @@ char *Sys_DefaultInstallPath(void); +@@ -1098,6 +1104,9 @@ char *Sys_DefaultAppPath(void); + #ifdef MACOS_X char *Sys_DefaultAppPath(void); #endif - ++ +void Sys_SetDefaultLibPath(const char *path); +char *Sys_DefaultLibPath(void); -+ + void Sys_SetDefaultHomePath(const char *path); char *Sys_DefaultHomePath(void); - const char *Sys_TempPath(void);