diff options
author | Zack Middleton <zturtleman@gmail.com> | 2013-04-24 14:11:18 -0500 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-05-03 16:11:37 +0100 |
commit | 25b80077d4c81af8ac922150598f82bddde808cb (patch) | |
tree | a0162af401d09effcd0ad2cd3406b6bd401b9a3b /src/qcommon | |
parent | 9d3c009673517a8edf82bf0e1f63eca4eadb4a28 (diff) |
Don't allow modifying qvms or pk3s
Exception for allowing pk3s to be downloaded.
Diffstat (limited to 'src/qcommon')
-rw-r--r-- | src/qcommon/files.c | 16 | ||||
-rw-r--r-- | src/qcommon/qcommon.h | 2 |
2 files changed, 11 insertions, 7 deletions
diff --git a/src/qcommon/files.c b/src/qcommon/files.c index a9c43b43..f3e4ba70 100644 --- a/src/qcommon/files.c +++ b/src/qcommon/files.c @@ -532,17 +532,19 @@ qboolean FS_CreatePath (char *OSPath) { ================= FS_CheckFilenameIsNotExecutable -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, const char *function ) { - // Check if the filename ends with the library extension - if(COM_CompareExtension(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", function, filename, DLL_EXT ); + "to %s extension", function, filename, COM_GetExtension( filename ) ); } } @@ -743,7 +745,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 ) { @@ -762,7 +764,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__ ); + if ( safe ) { + FS_CheckFilenameIsNotExecutable( to_ospath, __func__ ); + } rename(from_ospath, to_ospath); } diff --git a/src/qcommon/qcommon.h b/src/qcommon/qcommon.h index 6f235ee9..bf195ec7 100644 --- a/src/qcommon/qcommon.h +++ b/src/qcommon/qcommon.h @@ -622,7 +622,7 @@ fileHandle_t FS_FCreateOpenPipeFile( const char *filename ); fileHandle_t FS_SV_FOpenFileWrite( const char *filename ); long 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 ); long 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 |