mirror of
https://github.com/FWGS/xash3d-fwgs
synced 2024-11-22 09:56:22 +01:00
filesystem: strip upper directory access from FS_FindFile when FS_AllowDirectPath is set to true
Detailed explanation is available in the code comments.
This commit is contained in:
parent
281d4359d0
commit
0313e19674
@ -1940,6 +1940,17 @@ searchpath_t *FS_FindFile( const char *name, int *index, char *fixedname, size_t
|
|||||||
{
|
{
|
||||||
char netpath[MAX_SYSPATH], dirpath[MAX_SYSPATH];
|
char netpath[MAX_SYSPATH], dirpath[MAX_SYSPATH];
|
||||||
|
|
||||||
|
// HACKHACK: when the code wants to access to root game directory
|
||||||
|
// it often uses ../ in conjunction with FS_AllowDirectPath
|
||||||
|
// it results in the access above the root game directory
|
||||||
|
// FS_Open with "write" flag doesn't have this problem because
|
||||||
|
// it looks up relative to fs_writepath
|
||||||
|
// the correct solution MIGHT be using fs_writepath instead of fs_rootdir here?
|
||||||
|
// but this need to be properly tested so as a temporary solution
|
||||||
|
// just strip ../
|
||||||
|
if( !Q_strncmp( name, "../", 3 ))
|
||||||
|
name += 3;
|
||||||
|
|
||||||
Q_snprintf( dirpath, sizeof( dirpath ), "%s/", fs_rootdir );
|
Q_snprintf( dirpath, sizeof( dirpath ), "%s/", fs_rootdir );
|
||||||
Q_snprintf( netpath, sizeof( netpath ), "%s%s", dirpath, name );
|
Q_snprintf( netpath, sizeof( netpath ), "%s%s", dirpath, name );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user