diff options
Diffstat (limited to 'executor')
| -rw-r--r-- | executor/common_test.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/executor/common_test.h b/executor/common_test.h index 9d9adc36f..2ce410b36 100644 --- a/executor/common_test.h +++ b/executor/common_test.h @@ -101,6 +101,28 @@ static long syz_compare_int(volatile long n, ...) } #endif +#if SYZ_EXECUTOR || __NR_syz_compare_zlib +#include "common_zlib.h" +#include <errno.h> +#include <fcntl.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) +{ + int fd = open("./uncompressed", O_RDWR | O_CREAT | O_EXCL, 0666); + if (fd == -1) + return -1; + if (ftruncate(fd, size)) + return -1; + if (puff_zlib_to_file((unsigned char*)zdata, zsize, fd, size)) + return -1; + void* uncompressed = mmap(0, size, PROT_READ, MAP_PRIVATE, fd, 0); + if (uncompressed == MAP_FAILED) + return -1; + return syz_compare(data, size, (long)uncompressed, size); +} +#endif + #if SYZ_EXECUTOR || SYZ_SANDBOX_NONE static void loop(); static int do_sandbox_none(void) |
