[ioquake3] 43/136: Check for truncated paths in Sys_LoadDll
Simon McVittie
smcv at debian.org
Thu Jun 15 09:09:06 UTC 2017
This is an automated email from the git hooks/post-receive script.
smcv pushed a commit to branch debian/master
in repository ioquake3.
commit 70af7e673ff97147c863a995203074f5a02aa897
Author: Zack Middleton <zack at cloemail.com>
Date: Wed May 24 09:51:48 2017 -0500
Check for truncated paths in Sys_LoadDll
Check for truncated paths which could allow loading a library with
a non-standard extension. Also provides a better message for why a
valid library with a long path would fail to load.
---
code/sys/sys_main.c | 28 ++++++++++++++++++++++------
1 file changed, 22 insertions(+), 6 deletions(-)
diff --git a/code/sys/sys_main.c b/code/sys/sys_main.c
index 1e8a8a1..14179b9 100644
--- a/code/sys/sys_main.c
+++ b/code/sys/sys_main.c
@@ -513,16 +513,25 @@ void *Sys_LoadDll(const char *name, qboolean useSystemLib)
{
const char *topDir;
char libPath[MAX_OSPATH];
+ int len;
topDir = Sys_BinaryPath();
if(!*topDir)
topDir = ".";
- Com_Printf("Trying to load \"%s\" from \"%s\"...\n", name, topDir);
- Com_sprintf(libPath, sizeof(libPath), "%s%c%s", topDir, PATH_SEP, name);
+ len = Com_sprintf(libPath, sizeof(libPath), "%s%c%s", topDir, PATH_SEP, name);
+ if(len < sizeof(libPath))
+ {
+ Com_Printf("Trying to load \"%s\" from \"%s\"...\n", name, topDir);
+ dllhandle = Sys_LoadLibrary(libPath);
+ }
+ else
+ {
+ Com_Printf("Skipping trying to load \"%s\" from \"%s\", file name is too long.\n", name, topDir);
+ }
- if(!(dllhandle = Sys_LoadLibrary(libPath)))
+ if(!dllhandle)
{
const char *basePath = Cvar_VariableString("fs_basepath");
@@ -531,9 +540,16 @@ void *Sys_LoadDll(const char *name, qboolean useSystemLib)
if(FS_FilenameCompare(topDir, basePath))
{
- Com_Printf("Trying to load \"%s\" from \"%s\"...\n", name, basePath);
- Com_sprintf(libPath, sizeof(libPath), "%s%c%s", basePath, PATH_SEP, name);
- dllhandle = Sys_LoadLibrary(libPath);
+ len = Com_sprintf(libPath, sizeof(libPath), "%s%c%s", basePath, PATH_SEP, name);
+ if(len < sizeof(libPath))
+ {
+ Com_Printf("Trying to load \"%s\" from \"%s\"...\n", name, basePath);
+ dllhandle = Sys_LoadLibrary(libPath);
+ }
+ else
+ {
+ Com_Printf("Skipping trying to load \"%s\" from \"%s\", file name is too long.\n", name, basePath);
+ }
}
if(!dllhandle)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/ioquake3.git
More information about the Pkg-games-commits
mailing list