From e262a180fea1a04c047071cad96d53a2f4b233c3 Mon Sep 17 00:00:00 2001 From: Mel Date: Sat, 14 Jun 2025 01:11:57 +0200 Subject: Prevent mmap of empty file Signed-off-by: Mel --- boot/catboot.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/boot/catboot.c b/boot/catboot.c index 23b649e..79a5e2b 100644 --- a/boot/catboot.c +++ b/boot/catboot.c @@ -31,6 +31,8 @@ read_file(const ascii* path) struct stat stat_info; if (stat(path, &stat_info) == -1) failure("i couldn't open that file, sorry :("); + check(stat_info.st_size > 0, "file is empty, i can't map an empty file"); + const int32 file_descriptor = open(path, O_RDONLY); check(file_descriptor != -1, "i couldn't open that file, sorry :("); -- cgit 1.4.1