Skip to content

deps: update zlib to 1.3.0.1-motley-780819f #57768

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deps/zlib/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ source_set("zlib_common_headers") {
use_arm_neon_optimizations = false
if ((current_cpu == "arm" || current_cpu == "arm64") &&
!(is_win && !is_clang)) {
# TODO(richard.townsend@arm.com): Optimizations temporarily disabled for
# TODO(ritownsend@google.com): Optimizations temporarily disabled for
# Windows on Arm MSVC builds, see http://crbug.com/v8/10012.
if (arm_use_neon) {
use_arm_neon_optimizations = true
Expand Down
14 changes: 7 additions & 7 deletions deps/zlib/deflate.c
Original file line number Diff line number Diff line change
Expand Up @@ -485,14 +485,7 @@ int ZEXPORT deflateInit2_(z_streamp strm, int level, int method,
s->window = (Bytef *) ZALLOC(strm,
s->w_size + WINDOW_PADDING,
2*sizeof(Byte));
/* Avoid use of unitialized values in the window, see crbug.com/1137613 and
* crbug.com/1144420 */
zmemzero(s->window, (s->w_size + WINDOW_PADDING) * (2 * sizeof(Byte)));
s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos));
/* Avoid use of uninitialized value, see:
* https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=11360
*/
zmemzero(s->prev, s->w_size * sizeof(Pos));
s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos));

s->high_water = 0; /* nothing written to s->window yet */
Expand Down Expand Up @@ -551,6 +544,13 @@ int ZEXPORT deflateInit2_(z_streamp strm, int level, int method,
deflateEnd (strm);
return Z_MEM_ERROR;
}
/* Avoid use of unitialized values in the window, see crbug.com/1137613 and
* crbug.com/1144420 */
zmemzero(s->window, (s->w_size + WINDOW_PADDING) * (2 * sizeof(Byte)));
/* Avoid use of uninitialized value, see:
* https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=11360
*/
zmemzero(s->prev, s->w_size * sizeof(Pos));
#ifdef LIT_MEM
s->d_buf = (ushf *)(s->pending_buf + (s->lit_bufsize << 1));
s->l_buf = s->pending_buf + (s->lit_bufsize << 2);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
From 93f86001b67609106c658fe0908a9b7931245b8a Mon Sep 17 00:00:00 2001
From: pedro martelletto <martelletto@google.com>
Date: Thu, 3 Apr 2025 16:46:42 +0000
Subject: [PATCH] [zlib] Deflate: move zmemzero after NULL check

ZALLOC() might fail, in which case dereferencing the returned pointer
results in undefined behaviour. N.B. These conditions are not reachable
from Chromium, as Chromium will abort rather than return nullptr from
malloc. Found by libfido2's fuzz harness.
---
third_party/zlib/deflate.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/third_party/zlib/deflate.c b/third_party/zlib/deflate.c
index 8a5281c2b6cd8..49496bb3b0561 100644
--- a/third_party/zlib/deflate.c
+++ b/third_party/zlib/deflate.c
@@ -485,14 +485,7 @@ int ZEXPORT deflateInit2_(z_streamp strm, int level, int method,
s->window = (Bytef *) ZALLOC(strm,
s->w_size + WINDOW_PADDING,
2*sizeof(Byte));
- /* Avoid use of unitialized values in the window, see crbug.com/1137613 and
- * crbug.com/1144420 */
- zmemzero(s->window, (s->w_size + WINDOW_PADDING) * (2 * sizeof(Byte)));
s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos));
- /* Avoid use of uninitialized value, see:
- * https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=11360
- */
- zmemzero(s->prev, s->w_size * sizeof(Pos));
s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos));

s->high_water = 0; /* nothing written to s->window yet */
@@ -551,6 +544,13 @@ int ZEXPORT deflateInit2_(z_streamp strm, int level, int method,
deflateEnd (strm);
return Z_MEM_ERROR;
}
+ /* Avoid use of unitialized values in the window, see crbug.com/1137613 and
+ * crbug.com/1144420 */
+ zmemzero(s->window, (s->w_size + WINDOW_PADDING) * (2 * sizeof(Byte)));
+ /* Avoid use of uninitialized value, see:
+ * https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=11360
+ */
+ zmemzero(s->prev, s->w_size * sizeof(Pos));
#ifdef LIT_MEM
s->d_buf = (ushf *)(s->pending_buf + (s->lit_bufsize << 1));
s->l_buf = s->pending_buf + (s->lit_bufsize << 2);
--
2.49.0.504.g3bcea36a83-goog

2 changes: 1 addition & 1 deletion src/zlib_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
// Refer to tools/dep_updaters/update-zlib.sh
#ifndef SRC_ZLIB_VERSION_H_
#define SRC_ZLIB_VERSION_H_
#define ZLIB_VERSION "1.3.0.1-motley-788cb3c"
#define ZLIB_VERSION "1.3.0.1-motley-780819f"
#endif // SRC_ZLIB_VERSION_H_
Loading