From c692fab1c2ff0de2554c5940f77ac8c168e729b2 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Sat, 17 Dec 2022 15:08:10 +0100 Subject: pkg/image: treat empty compressed image as valid image When we decompress images for mutation or hints, we always specially check for empty compressed data (I assume it can apper after minimization). Treat it as correct compressed and return empty decompressed data. This removes the need in special handling in users. --- pkg/csource/generated.go | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'pkg/csource/generated.go') diff --git a/pkg/csource/generated.go b/pkg/csource/generated.go index 754feaa68..8c8fa8d22 100644 --- a/pkg/csource/generated.go +++ b/pkg/csource/generated.go @@ -6640,13 +6640,10 @@ static int puff( static int puff_zlib_to_file(const unsigned char* source, unsigned long sourcelen, int dest_fd) { - if (sourcelen < ZLIB_HEADER_WIDTH) { - errno = EMSGSIZE; - return -1; - } + if (sourcelen < ZLIB_HEADER_WIDTH) + return 0; source += ZLIB_HEADER_WIDTH; sourcelen -= ZLIB_HEADER_WIDTH; - const unsigned long max_destlen = 132 << 20; void* ret = mmap(0, max_destlen, PROT_WRITE | PROT_READ, MAP_PRIVATE | MAP_ANON, -1, 0); if (ret == MAP_FAILED) @@ -11783,13 +11780,10 @@ static int puff( static int puff_zlib_to_file(const unsigned char* source, unsigned long sourcelen, int dest_fd) { - if (sourcelen < ZLIB_HEADER_WIDTH) { - errno = EMSGSIZE; - return -1; - } + if (sourcelen < ZLIB_HEADER_WIDTH) + return 0; source += ZLIB_HEADER_WIDTH; sourcelen -= ZLIB_HEADER_WIDTH; - const unsigned long max_destlen = 132 << 20; void* ret = mmap(0, max_destlen, PROT_WRITE | PROT_READ, MAP_PRIVATE | MAP_ANON, -1, 0); if (ret == MAP_FAILED) -- cgit mrf-deployment