diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2025-07-11 19:37:52 +0200 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2025-07-14 09:13:10 +0000 |
| commit | d8fc733505f5adb1a84287028b9aabb4f8c56cf9 (patch) | |
| tree | 7bd862165a59c6c5266aab34ba74a13e23c7bb47 /executor/common_test.h | |
| parent | 21491a419f6eafd8f2b860c5add98ec80294a25c (diff) | |
executor: handle zero length in syz_compare_zlib
It used to fail because we cannot mmap 0 bytes.
Closes #6148.
Diffstat (limited to 'executor/common_test.h')
| -rw-r--r-- | executor/common_test.h | 10 |
1 files changed, 7 insertions, 3 deletions
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 |
