summaryrefslogtreecommitdiff
path: root/backport-Add-bounds-checking-to-ERR_MSG-macro-used-by-zError.patch
diff options
context:
space:
mode:
Diffstat (limited to 'backport-Add-bounds-checking-to-ERR_MSG-macro-used-by-zError.patch')
-rw-r--r--backport-Add-bounds-checking-to-ERR_MSG-macro-used-by-zError.patch27
1 files changed, 27 insertions, 0 deletions
diff --git a/backport-Add-bounds-checking-to-ERR_MSG-macro-used-by-zError.patch b/backport-Add-bounds-checking-to-ERR_MSG-macro-used-by-zError.patch
new file mode 100644
index 0000000..e4d75cf
--- /dev/null
+++ b/backport-Add-bounds-checking-to-ERR_MSG-macro-used-by-zError.patch
@@ -0,0 +1,27 @@
+From 431a9b65eacab7efabf2230ba97ff426c0e07f9d Mon Sep 17 00:00:00 2001
+From: Mark Adler <madler@alumni.caltech.edu>
+Date: Thu, 7 Dec 2023 06:38:10 -0800
+Subject: [PATCH] Add bounds checking to ERR_MSG() macro, used by zError().
+
+Reference: https://github.com/madler/zlib/commit/431a9b65eacab7efabf2230ba97ff426c0e07f9d
+Conflict: no
+---
+ zutil.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/zutil.h b/zutil.h
+index 902a304..0bd2dbc 100644
+--- a/zutil.h
++++ b/zutil.h
+@@ -56,7 +56,7 @@ typedef unsigned long ulg;
+ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
+ /* (size given to avoid silly warnings with Visual C++) */
+
+-#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
++#define ERR_MSG(err) z_errmsg[(err) < -6 || (err) > 2 ? 9 : 2 - (err)]
+
+ #define ERR_RETURN(strm,err) \
+ return (strm->msg = ERR_MSG(err), (err))
+--
+2.33.0
+