From 24857b29bc28753137e73565e8f9c26e67bf0770 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Tue, 22 Nov 2022 17:08:47 +0100 Subject: executor: don't pass uncompressed zlib size This will allow us to mutate the image size. Fixes #3527 --- executor/common_test.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'executor/common_test.h') 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 #include +#include // 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 -- cgit mrf-deployment