engine: validate paths before downloading

This commit is contained in:
Alibek Omarov
2026-05-17 10:41:59 +05:00
parent 5d7ed9d8a7
commit 9082a47348
2 changed files with 7 additions and 2 deletions

View File

@@ -18,7 +18,6 @@ GNU General Public License for more details.
#include "client.h" // ConnectionProgress
#include "netchan.h"
#include "xash3d_mathlib.h"
#include "ipv6text.h"
#include "net_ws_private.h"
#include "miniz.h"
@@ -943,6 +942,12 @@ void HTTP_AddDownload( const char *path, int size, qboolean process, resource_t
{
httpfile_t *httpfile;
if( COM_CheckNastyPath( path ))
{
Con_Printf( S_ERROR "%s: refused to download %s, nasty path\n", __func__, path );
return;
}
if( !http.first_server )
{
Con_Printf( S_ERROR "no servers to download %s\n", path );

View File

@@ -1233,7 +1233,7 @@ qboolean Netchan_CopyFileFragments( netchan_t *chan, sizebuf_t *msg )
Netchan_FlushIncoming( chan, FRAG_FILE_STREAM );
return false;
}
else if( filename[0] != '!' && !COM_IsSafeFileToDownload( filename ))
else if( filename[0] != '!' && ( COM_CheckNastyPath( filename ) || !COM_IsSafeFileToDownload( filename )))
{
Con_Printf( S_ERROR "file fragment received with bad path, ignoring\n" );
Netchan_FlushIncoming( chan, FRAG_FILE_STREAM );