Skip to content

Commit 9d344ce

Browse files
committed
ChicleFileMapping: Limit size of files we try to map/read
1 parent eaa2164 commit 9d344ce

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

tools/chafa/chicle-file-mapping.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@
6565
# endif
6666
#endif
6767

68+
/* The absolute maximum size file we'll try to open */
69+
#define FILE_SIZE_MAX ((gint64) 2 * 1024 * 1024 * 1024)
70+
6871
/* Streams bigger than this must be cached in a file */
6972
#define FILE_MEMORY_CACHE_MAX (4 * 1024 * 1024)
7073

@@ -465,6 +468,8 @@ map_or_read_file (ChicleFileMapping *file_mapping)
465468
goto out;
466469

467470
t = fstat (file_mapping->fd, &sbuf);
471+
if (sbuf.st_size > FILE_SIZE_MAX)
472+
goto out;
468473

469474
if (!t)
470475
{

0 commit comments

Comments
 (0)