|
| 1 | +From 901960817a6dc7b40c68c47bcd77037d5fc5d1ea Mon Sep 17 00:00:00 2001 |
| 2 | +From: Mitch Zhu <mitchzhu@microsoft.com> |
| 3 | +Date: Wed, 29 May 2024 19:11:14 +0000 |
| 4 | +Subject: [PATCH] Address CVE-2023-21100 |
| 5 | + |
| 6 | +If the extra field was larger than the space the user provided with |
| 7 | +inflateGetHeader(), and if multiple calls of inflate() delivered |
| 8 | +the extra header data, then there could be a buffer overflow of the |
| 9 | +provided space. This commit assures that provided space is not |
| 10 | +exceeded. |
| 11 | +--- |
| 12 | + deps/v8/third_party/zlib/contrib/optimizations/inflate.c | 5 +++-- |
| 13 | + deps/v8/third_party/zlib/inflate.c | 5 +++-- |
| 14 | + 2 files changed, 6 insertions(+), 4 deletions(-) |
| 15 | + |
| 16 | +diff --git a/deps/v8/third_party/zlib/contrib/optimizations/inflate.c b/deps/v8/third_party/zlib/contrib/optimizations/inflate.c |
| 17 | +index 4841cd96..1007f062 100644 |
| 18 | +--- a/deps/v8/third_party/zlib/contrib/optimizations/inflate.c |
| 19 | ++++ b/deps/v8/third_party/zlib/contrib/optimizations/inflate.c |
| 20 | +@@ -772,8 +772,9 @@ int flush; |
| 21 | + if (copy > have) copy = have; |
| 22 | + if (copy) { |
| 23 | + if (state->head != Z_NULL && |
| 24 | +- state->head->extra != Z_NULL) { |
| 25 | +- len = state->head->extra_len - state->length; |
| 26 | ++ state->head->extra != Z_NULL && |
| 27 | +++ (len = state->head->extra_len - state->length) < |
| 28 | +++ state->head->extra_max) { |
| 29 | + zmemcpy(state->head->extra + len, next, |
| 30 | + len + copy > state->head->extra_max ? |
| 31 | + state->head->extra_max - len : copy); |
| 32 | +diff --git a/deps/v8/third_party/zlib/inflate.c b/deps/v8/third_party/zlib/inflate.c |
| 33 | +index 7543c33d..384af93f 100644 |
| 34 | +--- a/deps/v8/third_party/zlib/inflate.c |
| 35 | ++++ b/deps/v8/third_party/zlib/inflate.c |
| 36 | +@@ -761,8 +761,9 @@ int flush; |
| 37 | + if (copy > have) copy = have; |
| 38 | + if (copy) { |
| 39 | + if (state->head != Z_NULL && |
| 40 | +- state->head->extra != Z_NULL) { |
| 41 | +- len = state->head->extra_len - state->length; |
| 42 | ++ state->head->extra != Z_NULL && |
| 43 | +++ (len = state->head->extra_len - state->length) < |
| 44 | +++ state->head->extra_max) { |
| 45 | + zmemcpy(state->head->extra + len, next, |
| 46 | + len + copy > state->head->extra_max ? |
| 47 | + state->head->extra_max - len : copy); |
| 48 | +-- |
| 49 | +2.34.1 |
| 50 | + |
0 commit comments