From f79f57c39c22db6d7bfb718cd08fe321c38b7f95 Mon Sep 17 00:00:00 2001 From: Thilo Schulz Date: Sun, 24 Jul 2011 22:12:21 +0000 Subject: Fix extension name comparison for DLL files --- src/qcommon/files.c | 2 +- src/qcommon/q_shared.c | 24 ++++++++++++++++++++++++ src/qcommon/q_shared.h | 1 + 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/qcommon/files.c b/src/qcommon/files.c index 8e32c9ff..72c8cffe 100644 --- a/src/qcommon/files.c +++ b/src/qcommon/files.c @@ -535,7 +535,7 @@ static void FS_CheckFilenameIsNotExecutable( const char *filename, const char *function ) { // Check if the filename ends with the library extension - if( !Q_stricmp( COM_GetExtension( filename ), DLL_EXT ) ) + if(COM_CompareExtension(filename, DLL_EXT)) { Com_Error( ERR_FATAL, "%s: Not allowed to manipulate '%s' due " "to %s extension", function, filename, DLL_EXT ); diff --git a/src/qcommon/q_shared.c b/src/qcommon/q_shared.c index d8bc7383..b1197a55 100644 --- a/src/qcommon/q_shared.c +++ b/src/qcommon/q_shared.c @@ -83,6 +83,30 @@ void COM_StripExtension( const char *in, char *out, int destsize ) Q_strncpyz(out, in, destsize); } +/* +============ +COM_CompareExtension + +string compare the end of the strings and return qtrue if strings match +============ +*/ +qboolean COM_CompareExtension(const char *in, const char *ext) +{ + int inlen, extlen; + + inlen = strlen(in); + extlen = strlen(ext); + + if(extlen <= inlen) + { + in += inlen - extlen; + + if(!Q_stricmp(in, ext)) + return qtrue; + } + + return qfalse; +} /* ================== diff --git a/src/qcommon/q_shared.h b/src/qcommon/q_shared.h index 5e701cc6..082a442f 100644 --- a/src/qcommon/q_shared.h +++ b/src/qcommon/q_shared.h @@ -756,6 +756,7 @@ float Com_Clamp( float min, float max, float value ); char *COM_SkipPath( char *pathname ); const char *COM_GetExtension( const char *name ); void COM_StripExtension(const char *in, char *out, int destsize); +qboolean COM_CompareExtension(const char *in, const char *ext); void COM_DefaultExtension( char *path, int maxSize, const char *extension ); void COM_BeginParseSession( const char *name ); -- cgit