From 3c522386e961d61768ea527d04713b5402356dd4 Mon Sep 17 00:00:00 2001 From: yhirose Date: Sun, 12 Sep 2021 19:24:48 -0400 Subject: [PATCH] Fix "Issue 38551 in oss-fuzz: cpp-httplib:server_fuzzer: Timeout in server_fuzze" --- httplib.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/httplib.h b/httplib.h index fae47fa..392f895 100644 --- a/httplib.h +++ b/httplib.h @@ -2971,7 +2971,14 @@ inline bool gzip_decompressor::decompress(const char *data, size_t data_length, strm_.avail_out = static_cast(buff.size()); strm_.next_out = reinterpret_cast(buff.data()); + auto prev_avail_in = strm_.avail_in; + ret = inflate(&strm_, Z_NO_FLUSH); + + if (prev_avail_in - strm_.avail_in == 0) { + return false; + } + assert(ret != Z_STREAM_ERROR); switch (ret) { case Z_NEED_DICT: