diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2022-11-22 17:08:47 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2022-11-23 09:09:39 +0100 |
| commit | 24857b29bc28753137e73565e8f9c26e67bf0770 (patch) | |
| tree | 8de7ced0fec1570a2e81e6cf13e9be8363e9563a /executor/common_test.h | |
| parent | 0313f19c6536a190992aff148a0960c7fea6e47f (diff) | |
executor: don't pass uncompressed zlib size
This will allow us to mutate the image size.
Fixes #3527
Diffstat (limited to 'executor/common_test.h')
| -rw-r--r-- | executor/common_test.h | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/executor/common_test.h b/executor/common_test.h index 2ce410b36..6ef6ed82d 100644 --- a/executor/common_test.h +++ b/executor/common_test.h @@ -105,6 +105,7 @@ static long syz_compare_int(volatile long n, ...) #include "common_zlib.h" #include <errno.h> #include <fcntl.h> +#include <sys/stat.h> // syz_compare_zlib(data ptr[in, array[int8]], size bytesize[data], zdata ptr[in, compressed_image], zsize bytesize[zdata]) static long syz_compare_zlib(volatile long data, volatile long size, volatile long zdata, volatile long zsize) @@ -112,14 +113,15 @@ static long syz_compare_zlib(volatile long data, volatile long size, volatile lo int fd = open("./uncompressed", O_RDWR | O_CREAT | O_EXCL, 0666); if (fd == -1) return -1; - if (ftruncate(fd, size)) + if (puff_zlib_to_file((unsigned char*)zdata, zsize, fd)) return -1; - if (puff_zlib_to_file((unsigned char*)zdata, zsize, fd, size)) + struct stat statbuf; + if (fstat(fd, &statbuf)) return -1; - void* uncompressed = mmap(0, size, PROT_READ, MAP_PRIVATE, fd, 0); + void* 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, size); + return syz_compare(data, size, (long)uncompressed, statbuf.st_size); } #endif |
