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;
|
const char *topDir;
|
||||||
char libPath[MAX_OSPATH];
|
char libPath[MAX_OSPATH];
|
||||||
|
int len;
|
||||||
|
|
||||||
topDir = Sys_BinaryPath();
|
topDir = Sys_BinaryPath();
|
||||||
|
|
||||||
if(!*topDir)
|
if(!*topDir)
|
||||||
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_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");
|
const char *basePath = Cvar_VariableString("fs_basepath");
|
||||||
|
|
||||||
|
@ -530,11 +539,18 @@ void *Sys_LoadDll(const char *name, qboolean useSystemLib)
|
||||||
basePath = ".";
|
basePath = ".";
|
||||||
|
|
||||||
if(FS_FilenameCompare(topDir, 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_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);
|
dllhandle = Sys_LoadLibrary(libPath);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Com_Printf("Skipping trying to load \"%s\" from \"%s\", file name is too long.\n", name, basePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(!dllhandle)
|
if(!dllhandle)
|
||||||
Com_Printf("Loading \"%s\" failed\n", name);
|
Com_Printf("Loading \"%s\" failed\n", name);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue