Skip to content

Commit b5f774b

Browse files
committed
Don't allow loading console font from pak file
Home path can still be used.
1 parent e2fe98d commit b5f774b

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/engine/renderer/tr_font.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -425,21 +425,29 @@ static int RE_LoadFontFile( const char *name, void **buffer )
425425
return sizeof( daemon_unifont_bin );
426426
}
427427

428-
void *tmp;
429-
int length = ri.FS_ReadFile( name, &tmp );
428+
std::string tmp;
430429

431-
if ( length <= 0 )
430+
try
431+
{
432+
tmp = FS::HomePath::OpenRead( name ).ReadAll();
433+
}
434+
catch ( const std::system_error &exc )
435+
{
436+
Log::Warn( "Failed to read font file: %s", exc.what() );
437+
return 0;
438+
}
439+
440+
if ( tmp.size() > 1000 * 1000 * 1000 )
432441
{
433442
return 0;
434443
}
435444

436-
void *data = Z_AllocUninit( length );
445+
void *data = Z_AllocUninit( tmp.size() );
437446
*buffer = data;
438447

439-
memcpy( data, tmp, length );
440-
ri.FS_FreeFile( tmp );
448+
memcpy( data, tmp.data(), tmp.size() );
441449

442-
return length;
450+
return tmp.size();
443451
}
444452

445453
static void RE_FreeFontFile( void *data )

0 commit comments

Comments
 (0)