From a9e14e85415eb326000f352bce3fcb04a125406d Mon Sep 17 00:00:00 2001 From: Mark Adler Date: Thu, 6 Oct 2022 16:33:42 -0700 Subject: [PATCH] Avoid undefined negation behavior if windowBits is INT_MIN. --- deflate.c | 2 ++ inflate.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/deflate.c b/deflate.c index 0345980..a578b1a 100644 --- a/deflate.c +++ b/deflate.c @@ -279,6 +279,8 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, if (windowBits < 0) { /* suppress zlib wrapper */ wrap = 0; + if (windowBits < -15) + return Z_STREAM_ERROR; windowBits = -windowBits; } #ifdef GZIP diff --git a/inflate.c b/inflate.c index 2a3c4fe..8acbef4 100644 --- a/inflate.c +++ b/inflate.c @@ -168,6 +168,8 @@ int windowBits; /* extract wrap request from windowBits parameter */ if (windowBits < 0) { + if (windowBits < -15) + return Z_STREAM_ERROR; wrap = 0; windowBits = -windowBits; }