Skip to content
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

deps: update zlib to 1.2.13.1-motley-3f0af7f #49677

Closed
wants to merge 2 commits into from
Closed
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
53 changes: 53 additions & 0 deletions deps/zlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ check_include_file(stddef.h HAVE_STDDEF_H)
option(ENABLE_SIMD_OPTIMIZATIONS "Enable all SIMD optimizations" OFF)
option(ENABLE_SIMD_AVX512 "Enable SIMD AXV512 optimizations" OFF)
option(USE_ZLIB_RABIN_KARP_HASH "Enable bitstream compatibility with canonical zlib" OFF)
option(BUILD_UNITTESTS "Enable standalone unit tests build" OFF)

if (USE_ZLIB_RABIN_KARP_HASH)
add_definitions(-DUSE_ZLIB_RABIN_KARP_ROLLING_HASH)
Expand Down Expand Up @@ -244,6 +245,58 @@ set(CMAKE_CXX_STANDARD 14) # workaround for older compilers (e.g. g++ 5.4).
add_executable(zlib_bench contrib/bench/zlib_bench.cc)
target_link_libraries(zlib_bench zlib)

#============================================================================
# Unit Tests
#============================================================================
if (BUILD_UNITTESTS)
include (ExternalProject)
set_directory_properties(PROPERTIES EP_PREFIX ${CMAKE_BINARY_DIR}/third_party)
ExternalProject_add(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG d1467f5813f4d363cfd11aba99c4e9fe47a85e99
UPDATE_COMMAND ""
INSTALL_COMMAND ""
LOG_DOWNLOAD ON
LOG_CONFIGURE ON
LOG_BUILD ON
)

# gtest includedir
ExternalProject_Get_Property(googletest source_dir)
set(GTEST_INCLUDE_DIRS
${source_dir}/googletest/include
${source_dir}/googletest/include/gtest
)

# gtest library
ExternalProject_Get_Property(googletest binary_dir)
set(GTEST_LIBRARY_PATH ${binary_dir}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gtest.a)
set(GTEST_LIBRARY gtest)
add_library(${GTEST_LIBRARY} UNKNOWN IMPORTED)
set_property(TARGET ${GTEST_LIBRARY} PROPERTY IMPORTED_LOCATION ${GTEST_LIBRARY_PATH})
add_dependencies(${GTEST_LIBRARY} googletest)

set(UTEST_SRC
${CMAKE_CURRENT_SOURCE_DIR}/contrib/tests/infcover.cc
${CMAKE_CURRENT_SOURCE_DIR}/contrib/tests/infcover.h
${CMAKE_CURRENT_SOURCE_DIR}/contrib/tests/utils_unittest.cc
${CMAKE_CURRENT_SOURCE_DIR}/contrib/tests/standalone_test_runner.cc
${CMAKE_CURRENT_SOURCE_DIR}/google/compression_utils_portable.cc
)

add_compile_definitions(CMAKE_STANDALONE_UNITTESTS)

add_executable(zlib_unittests ${UTEST_SRC})
target_include_directories(zlib_unittests PUBLIC ${GTEST_INCLUDE_DIRS})
target_include_directories(zlib_unittests PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/google)

target_link_libraries(zlib_unittests ${GTEST_LIBRARY})
target_link_libraries(zlib_unittests zlib)
# Needed by gtest
target_link_libraries(zlib_unittests pthread)
endif()

#============================================================================
# Minigzip tool
#============================================================================
Expand Down
2 changes: 1 addition & 1 deletion deps/zlib/README.chromium
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Version: 1.2.13
CPEPrefix: cpe:/a:zlib:zlib:1.2.13
Security Critical: yes
Shipped: yes
License: Custom license
License: Zlib
License File: LICENSE
License Android Compatible: yes

Expand Down
5 changes: 3 additions & 2 deletions deps/zlib/contrib/optimizations/inflate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1488,8 +1488,9 @@ int ZEXPORT inflateCopy(z_streamp dest, z_streamp source) {
if (copy == Z_NULL) return Z_MEM_ERROR;
window = Z_NULL;
if (state->window != Z_NULL) {
window = (unsigned char FAR *)
ZALLOC(source, 1U << state->wbits, sizeof(unsigned char));
window = (unsigned char FAR *)ZALLOC(
source, (1U << state->wbits) + CHUNKCOPY_CHUNK_SIZE,
sizeof(unsigned char));
if (window == Z_NULL) {
ZFREE(source, copy);
return Z_MEM_ERROR;
Expand Down
9 changes: 9 additions & 0 deletions deps/zlib/contrib/tests/standalone_test_runner.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the Chromium source repository LICENSE file.
#include <gtest/gtest.h>

int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
14 changes: 12 additions & 2 deletions deps/zlib/contrib/tests/utils_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@
#include <cstddef>
#include <vector>

#include "base/files/file_path.h"
#include "base/files/scoped_temp_dir.h"
#include "compression_utils_portable.h"
#include "gtest.h"

#if !defined(CMAKE_STANDALONE_UNITTESTS)
#include "base/files/file_path.h"
#include "base/files/scoped_temp_dir.h"

#include "third_party/zlib/contrib/minizip/unzip.h"
#include "third_party/zlib/contrib/minizip/zip.h"
#endif

#include "zlib.h"

void TestPayloads(size_t input_size, zlib_internal::WrapperType type) {
Expand Down Expand Up @@ -1020,6 +1025,9 @@ TEST(ZlibTest, DeflateZFixedCorruption) {
0);
}

// TODO(gustavoa): make these tests run standalone.
#ifndef CMAKE_STANDALONE_UNITTESTS

TEST(ZlibTest, ZipFilenameCommentSize) {
// Check that minizip rejects zip member filenames or comments longer than
// the zip format can represent.
Expand Down Expand Up @@ -1138,3 +1146,5 @@ TEST(ZlibTest, ZipExtraFieldSize) {
EXPECT_EQ(unzGoToNextFile(uzf), UNZ_END_OF_LIST_OF_FILE);
EXPECT_EQ(unzClose(uzf), UNZ_OK);
}

#endif
3 changes: 2 additions & 1 deletion deps/zlib/google/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ include_rules = [
'+base',
'+build',
'+testing',
"+third_party/zlib/zlib.h",
'+third_party/icu/source/i18n/unicode',
'+third_party/zlib/zlib.h',
]
13 changes: 7 additions & 6 deletions deps/zlib/google/zip_internal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,13 @@ zip_fileinfo TimeToZipFileInfo(const base::Time& file_time) {
// It assumes that dates below 1980 are in the double digit format.
// Hence the fail safe option is to leave the date unset. Some programs
// might show the unset date as 1980-0-0 which is invalid.
zip_info.tmz_date.tm_year = file_time_parts.year;
zip_info.tmz_date.tm_mon = file_time_parts.month - 1;
zip_info.tmz_date.tm_mday = file_time_parts.day_of_month;
zip_info.tmz_date.tm_hour = file_time_parts.hour;
zip_info.tmz_date.tm_min = file_time_parts.minute;
zip_info.tmz_date.tm_sec = file_time_parts.second;
zip_info.tmz_date = {
.tm_sec = static_cast<uInt>(file_time_parts.second),
.tm_min = static_cast<uInt>(file_time_parts.minute),
.tm_hour = static_cast<uInt>(file_time_parts.hour),
.tm_mday = static_cast<uInt>(file_time_parts.day_of_month),
.tm_mon = static_cast<uInt>(file_time_parts.month - 1),
.tm_year = static_cast<uInt>(file_time_parts.year)};
}

return zip_info;
Expand Down
16 changes: 8 additions & 8 deletions deps/zlib/google/zip_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -246,14 +246,14 @@ bool ZipReader::OpenEntry() {

// Construct the last modified time. The timezone info is not present in ZIP
// archives, so we construct the time as UTC.
base::Time::Exploded exploded_time = {};
exploded_time.year = info.tmu_date.tm_year;
exploded_time.month = info.tmu_date.tm_mon + 1; // 0-based vs 1-based
exploded_time.day_of_month = info.tmu_date.tm_mday;
exploded_time.hour = info.tmu_date.tm_hour;
exploded_time.minute = info.tmu_date.tm_min;
exploded_time.second = info.tmu_date.tm_sec;
exploded_time.millisecond = 0;
const base::Time::Exploded exploded_time = {
.year = static_cast<int>(info.tmu_date.tm_year),
.month =
static_cast<int>(info.tmu_date.tm_mon + 1), // 0-based vs 1-based
.day_of_month = static_cast<int>(info.tmu_date.tm_mday),
.hour = static_cast<int>(info.tmu_date.tm_hour),
.minute = static_cast<int>(info.tmu_date.tm_min),
.second = static_cast<int>(info.tmu_date.tm_sec)};

if (!base::Time::FromUTCExploded(exploded_time, &entry_.last_modified))
entry_.last_modified = base::Time::UnixEpoch();
Expand Down
34 changes: 10 additions & 24 deletions deps/zlib/google/zip_reader_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/hash/md5.h"
#include "base/i18n/time_formatting.h"
#include "base/path_service.h"
#include "base/run_loop.h"
#include "base/strings/string_piece.h"
Expand All @@ -31,6 +32,7 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
#include "third_party/icu/source/i18n/unicode/timezone.h"
#include "third_party/zlib/google/zip_internal.h"

using ::testing::_;
Expand Down Expand Up @@ -288,18 +290,10 @@ TEST_F(ZipReaderTest, RegularFile) {

EXPECT_EQ(target_path, entry->path);
EXPECT_EQ(13527, entry->original_size);

// The expected time stamp: 2009-05-29 06:22:20
base::Time::Exploded exploded = {}; // Zero-clear.
entry->last_modified.UTCExplode(&exploded);
EXPECT_EQ(2009, exploded.year);
EXPECT_EQ(5, exploded.month);
EXPECT_EQ(29, exploded.day_of_month);
EXPECT_EQ(6, exploded.hour);
EXPECT_EQ(22, exploded.minute);
EXPECT_EQ(20, exploded.second);
EXPECT_EQ(0, exploded.millisecond);

EXPECT_EQ("2009-05-29 06:22:20.000",
base::UnlocalizedTimeFormatWithPattern(entry->last_modified,
"y-MM-dd HH:mm:ss.SSS",
icu::TimeZone::getGMT()));
EXPECT_FALSE(entry->is_unsafe);
EXPECT_FALSE(entry->is_directory);
}
Expand Down Expand Up @@ -396,18 +390,10 @@ TEST_F(ZipReaderTest, Directory) {
EXPECT_EQ(target_path, entry->path);
// The directory size should be zero.
EXPECT_EQ(0, entry->original_size);

// The expected time stamp: 2009-05-31 15:49:52
base::Time::Exploded exploded = {}; // Zero-clear.
entry->last_modified.UTCExplode(&exploded);
EXPECT_EQ(2009, exploded.year);
EXPECT_EQ(5, exploded.month);
EXPECT_EQ(31, exploded.day_of_month);
EXPECT_EQ(15, exploded.hour);
EXPECT_EQ(49, exploded.minute);
EXPECT_EQ(52, exploded.second);
EXPECT_EQ(0, exploded.millisecond);

EXPECT_EQ("2009-05-31 15:49:52.000",
base::UnlocalizedTimeFormatWithPattern(entry->last_modified,
"y-MM-dd HH:mm:ss.SSS",
icu::TimeZone::getGMT()));
EXPECT_FALSE(entry->is_unsafe);
EXPECT_TRUE(entry->is_directory);
}
Expand Down
6 changes: 3 additions & 3 deletions doc/contributing/maintaining/maintaining-dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ This a list of all the dependencies:
* [undici 5.25.2][]
* [uvwasi 0.0.19][]
* [V8 11.3.244.8][]
* [zlib 1.2.13.1-motley-f5fd0ad][]
* [zlib 1.2.13.1-motley-3f0af7f][]

Any code which meets one or more of these conditions should
be managed as a dependency:
Expand Down Expand Up @@ -311,7 +311,7 @@ See [maintaining-web-assembly][] for more informations.
high-performance JavaScript and WebAssembly engine, written in C++.
See [maintaining-V8][] for more informations.

### zlib 1.2.13.1-motley-f5fd0ad
### zlib 1.2.13.1-motley-3f0af7f

The [zlib](https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/zlib)
dependency lossless data-compression library,
Expand Down Expand Up @@ -349,4 +349,4 @@ performance improvements not currently available in standard zlib.
[update-openssl-action]: ../../../.github/workflows/update-openssl.yml
[uvwasi 0.0.19]: #uvwasi-0019
[v8 11.3.244.8]: #v8-1132448
[zlib 1.2.13.1-motley-f5fd0ad]: #zlib-12131-motley-f5fd0ad
[zlib 1.2.13.1-motley-3f0af7f]: #zlib-12131-motley-3f0af7f
Loading