mirror of
https://github.com/ioquake/ioq3.git
synced 2024-11-10 07:11:46 +00:00
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.
This commit is contained in:
parent
05858d30e8
commit
70af7e673f
1 changed files with 22 additions and 6 deletions
|
@ -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 = ".";
|
||||
|
||||
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);
|
||||
Com_sprintf(libPath, sizeof(libPath), "%s%c%s", topDir, PATH_SEP, name);
|
||||
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");
|
||||
|
||||
|
@ -530,11 +539,18 @@ void *Sys_LoadDll(const char *name, qboolean useSystemLib)
|
|||
basePath = ".";
|
||||
|
||||
if(FS_FilenameCompare(topDir, basePath))
|
||||
{
|
||||
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);
|
||||
Com_sprintf(libPath, sizeof(libPath), "%s%c%s", basePath, PATH_SEP, name);
|
||||
dllhandle = Sys_LoadLibrary(libPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
Com_Printf("Skipping trying to load \"%s\" from \"%s\", file name is too long.\n", name, basePath);
|
||||
}
|
||||
}
|
||||
|
||||
if(!dllhandle)
|
||||
Com_Printf("Loading \"%s\" failed\n", name);
|
||||
|
|
Loading…
Reference in a new issue