xref: /aosp_15_r20/external/zlib/patches/0009-infcover-oob.patch (revision 86ee64e75fa5f8bce2c8c356138035642429cd05)
1From 75690b2683667be5535ac6243438115dc9c40f6a Mon Sep 17 00:00:00 2001
2From: Florian Mayer <[email protected]>
3Date: Wed, 16 Mar 2022 16:38:36 -0700
4Subject: [PATCH] Fix out of bounds in infcover.c.
5
6---
7 test/infcover.c | 4 +++-
8 1 file changed, 3 insertions(+), 1 deletion(-)
9
10diff --git a/test/infcover.c b/test/infcover.c
11index 2be01646c..a6d83693c 100644
12--- a/test/infcover.c
13+++ b/test/infcover.c
14@@ -373,7 +373,9 @@ local void cover_support(void)
15     mem_setup(&strm);
16     strm.avail_in = 0;
17     strm.next_in = Z_NULL;
18-    ret = inflateInit_(&strm, ZLIB_VERSION - 1, (int)sizeof(z_stream));
19+    char versioncpy[] = ZLIB_VERSION;
20+    versioncpy[0] -= 1;
21+    ret = inflateInit_(&strm, versioncpy, (int)sizeof(z_stream));
22                                                 assert(ret == Z_VERSION_ERROR);
23     mem_done(&strm, "wrong version");
24
25