diff options
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 |
