From d8fc733505f5adb1a84287028b9aabb4f8c56cf9 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Fri, 11 Jul 2025 19:37:52 +0200 Subject: executor: handle zero length in syz_compare_zlib It used to fail because we cannot mmap 0 bytes. Closes #6148. --- executor/common_test.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'executor/common_test.h') diff --git a/executor/common_test.h b/executor/common_test.h index f5f54d9ee..148f11f86 100644 --- a/executor/common_test.h +++ b/executor/common_test.h @@ -118,9 +118,13 @@ static long syz_compare_zlib(volatile long data, volatile long size, volatile lo struct stat statbuf; if (fstat(fd, &statbuf)) return -1; - void* uncompressed = mmap(0, statbuf.st_size, PROT_READ, MAP_PRIVATE, fd, 0); - if (uncompressed == MAP_FAILED) - return -1; + void* uncompressed = NULL; + if (statbuf.st_size > 0) { + // We cannot mmap 0 bytes. + uncompressed = mmap(0, statbuf.st_size, PROT_READ, MAP_PRIVATE, fd, 0); + if (uncompressed == MAP_FAILED) + return -1; + } return syz_compare(data, size, (long)uncompressed, statbuf.st_size); } #endif -- cgit mrf-deployment