Skip to content

Commit e99e06f

Browse files
miklelappoCogitri
authored andcommitted
(conan-io#13412) Bug/zlib/CVE 2022 37434
* zlib: Fix CVE-2022-37434 Apply CVE fix and a fix of CVE fix madler/zlib#686 openwrt/openwrt#10582 * Fix linter * Add patches description * Fix review
1 parent 07522ff commit e99e06f

6 files changed

+81
-5
lines changed

recipes/zlib/all/conandata.yml

+11-1
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,18 @@ patches:
99
"1.2.12":
1010
- patch_file: "patches/0001-fix-cmake.patch"
1111
- patch_file: "patches/0002-gzguts-xcode12-compile-fix.patch"
12+
- patch_file: "patches/0004-Fix-a-bug-when-getting-a-gzip-header-extra-field-wit.patch"
13+
patch_description: "CVE-2022-37434: Fix a bug when getting a gzip header extra field with inflate()"
14+
patch_type: "vulnerability"
15+
patch_source: "https://github.com/madler/zlib/commit/eff308af425b67093bab25f80f1ae950166bece1"
16+
sha256: "15e3c177dc2a034a22e02490a97ba5b1719aae3f8129a06c16d727b661d1650f"
17+
- patch_file: "patches/0005-Fix-extra-field-processing-bug-that-dereferences-NUL.patch"
18+
patch_description: "CVE-2022-37434: Fix extra field processing bug that dereferences NULL state->head"
19+
patch_type: "vulnerability"
20+
patch_source: "https://github.com/madler/zlib/commit/1eb7682f845ac9e9bf9ae35bbfb3bad5dacbd91d"
21+
sha256: "cdd69eb3251728b1875c8ecae6427b50aa750b4045ef984ab79b6c07b7e6dd3a"
1222
"1.2.11":
1323
- patch_file: "patches/0001-fix-cmake.patch"
1424
- patch_file: "patches/0002-gzguts-xcode12-compile-fix.patch"
15-
# https://github.com/madler/zlib/issues/268
25+
# https://github.com/madler/zlib/issues/268
1626
- patch_file: "patches/0003-gzguts-fix-widechar-condition.patch"

recipes/zlib/all/conanfile.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from conan.tools.scm import Version
66
import os
77

8-
required_conan_version = ">=1.46.0"
8+
required_conan_version = ">=1.49.0"
99

1010

1111
class ZlibConan(ConanFile):
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
From eff308af425b67093bab25f80f1ae950166bece1 Mon Sep 17 00:00:00 2001
2+
From: Mark Adler <fork@madler.net>
3+
Date: Sat, 30 Jul 2022 15:51:11 -0700
4+
Subject: [PATCH] Fix a bug when getting a gzip header extra field with
5+
inflate().
6+
7+
If the extra field was larger than the space the user provided with
8+
inflateGetHeader(), and if multiple calls of inflate() delivered
9+
the extra header data, then there could be a buffer overflow of the
10+
provided space. This commit assures that provided space is not
11+
exceeded.
12+
---
13+
inflate.c | 5 +++--
14+
1 file changed, 3 insertions(+), 2 deletions(-)
15+
16+
diff --git a/inflate.c b/inflate.c
17+
index 7be8c63..7a72897 100644
18+
--- a/inflate.c
19+
+++ b/inflate.c
20+
@@ -763,9 +763,10 @@ int flush;
21+
copy = state->length;
22+
if (copy > have) copy = have;
23+
if (copy) {
24+
+ len = state->head->extra_len - state->length;
25+
if (state->head != Z_NULL &&
26+
- state->head->extra != Z_NULL) {
27+
- len = state->head->extra_len - state->length;
28+
+ state->head->extra != Z_NULL &&
29+
+ len < state->head->extra_max) {
30+
zmemcpy(state->head->extra + len, next,
31+
len + copy > state->head->extra_max ?
32+
state->head->extra_max - len : copy);
33+
--
34+
2.25.1
35+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
From 1eb7682f845ac9e9bf9ae35bbfb3bad5dacbd91d Mon Sep 17 00:00:00 2001
2+
From: Mark Adler <fork@madler.net>
3+
Date: Mon, 8 Aug 2022 10:50:09 -0700
4+
Subject: [PATCH] Fix extra field processing bug that dereferences NULL
5+
state->head.
6+
7+
The recent commit to fix a gzip header extra field processing bug
8+
introduced the new bug fixed here.
9+
---
10+
inflate.c | 4 ++--
11+
1 file changed, 2 insertions(+), 2 deletions(-)
12+
13+
diff --git a/inflate.c b/inflate.c
14+
index 7a72897..2a3c4fe 100644
15+
--- a/inflate.c
16+
+++ b/inflate.c
17+
@@ -763,10 +763,10 @@ int flush;
18+
copy = state->length;
19+
if (copy > have) copy = have;
20+
if (copy) {
21+
- len = state->head->extra_len - state->length;
22+
if (state->head != Z_NULL &&
23+
state->head->extra != Z_NULL &&
24+
- len < state->head->extra_max) {
25+
+ (len = state->head->extra_len - state->length) <
26+
+ state->head->extra_max) {
27+
zmemcpy(state->head->extra + len, next,
28+
len + copy > state->head->extra_max ?
29+
state->head->extra_max - len : copy);
30+
--
31+
2.25.1
32+

recipes/zlib/all/test_package/conanfile.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from conan import ConanFile
2-
from conan.tools.build import cross_building
2+
from conan.tools.build import can_run
33
from conan.tools.cmake import CMake, cmake_layout
44
import os
55

@@ -20,6 +20,6 @@ def build(self):
2020
cmake.build()
2121

2222
def test(self):
23-
if not cross_building(self):
23+
if can_run(self):
2424
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
2525
self.run(bin_path, env="conanrun")

recipes/zlib/all/test_v1_package/conanfile.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# pylint: skip-file
21
from conans import ConanFile, CMake, tools
32
import os
43

0 commit comments

Comments
 (0)