Skip to content
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: 2 additions & 0 deletions deps/zlib/contrib/minizip/unzip.c
Original file line number Diff line number Diff line change
Expand Up @@ -1439,6 +1439,8 @@ local int unz64local_CheckCurrentFileCoherencyHeader(unz64_s* s, uInt* piSizeVar
*/
if (unz64local_getShort(&s->z_filefunc, s->filestream,&uFlags) != UNZ_OK)
err=UNZ_ERRNO;
else if ((err==UNZ_OK) && ((uFlags & 1) != (s->cur_file_info.flag & 1)))
err=UNZ_BADZIPFILE; /* LFH/CD encryption flag mismatch */

if (unz64local_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK)
err=UNZ_ERRNO;
Expand Down
23 changes: 23 additions & 0 deletions deps/zlib/contrib/tests/utils_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1424,6 +1424,29 @@ TEST(ZlibTest, ZipUnicodePathExtra) {
EXPECT_EQ(unzClose(uzf), UNZ_OK);
}

TEST(ZlibTest, ZipEncryptionFlagMismatch) {
// Test archive created with info-zip:
// $ echo -n a > a && zip -P a -k a.zip a
// and then hex-edited to drop the encrypted flag from the central directory.
base::FilePath zip_file = TestDataDir().AppendASCII("enc_flag_mismatch.zip");

unzFile uzf = unzOpen(zip_file.AsUTF8Unsafe().c_str());
ASSERT_NE(uzf, nullptr);

char name[100];
unz_file_info file_info;

ASSERT_EQ(unzGoToFirstFile(uzf), UNZ_OK);
ASSERT_EQ(unzGetCurrentFileInfo(uzf, &file_info, name, sizeof(name),
nullptr, 0, nullptr, 0), UNZ_OK);
ASSERT_EQ(std::string(name), "A");

// minizip should reject the member due to lfh/cd encrypted flag mismatch.
EXPECT_EQ(unzOpenCurrentFilePassword(uzf, "a"), UNZ_BADZIPFILE);

EXPECT_EQ(unzClose(uzf), UNZ_OK);
}

TEST(ZlibTest, Crbug500521311) {
base::FilePath zip_file = TestDataDir().AppendASCII("bug500521311.zip");
unzFile uzf = unzOpen(zip_file.AsUTF8Unsafe().c_str());
Expand Down
Binary file added deps/zlib/google/test/data/enc_flag_mismatch.zip
Binary file not shown.
1 change: 1 addition & 0 deletions deps/zlib/google/test_data.filelist
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ test/data/bug500521311.zip
test/data/create_symlink_test_zips.py
test/data/create_test_zip.sh
test/data/empty.zip
test/data/enc_flag_mismatch.zip
test/data/evil.zip
test/data/evil_via_absolute_file_name.zip
test/data/evil_via_invalid_utf8.zip
Expand Down
18 changes: 18 additions & 0 deletions deps/zlib/google/zip_reader_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,24 @@ TEST_F(ZipReaderTest, EncryptedFile_RightPassword) {
EXPECT_TRUE(reader.ok());
}

// An entry whose local file header has the "encrypted" general-purpose flag
// bit set while the central directory does not should be rejected.
TEST_F(ZipReaderTest, MismatchedEncryptionFlag) {
ZipReader reader;
ASSERT_TRUE(reader.Open(data_dir_.AppendASCII("enc_flag_mismatch.zip")));

const ZipReader::Entry* entry = reader.Next();
ASSERT_TRUE(entry);
EXPECT_EQ(base::FilePath::FromASCII("A"), entry->path);
EXPECT_FALSE(entry->is_directory);
std::string contents = "dummy";
EXPECT_FALSE(reader.ExtractCurrentEntryToString(&contents));
EXPECT_EQ("", contents);

EXPECT_FALSE(reader.Next());
EXPECT_TRUE(reader.ok());
}

// Verifies that the ZipReader class can extract a file from a zip archive
// stored in memory. This test opens a zip archive in a std::string object,
// extracts its content, and verifies the content is the same as the expected
Expand Down
28 changes: 28 additions & 0 deletions deps/zlib/patches/0015-minizip-unzip-enable-decryption.patch
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,31 @@ index 82275d6c1775d..c8a01b23efd42 100644
s->encrypted=1;
}
# endif

commit 874ed6b46a4f75407829e510db77cc673a4c86e7
Author: Hans Wennborg <hans@chromium.org>
Date: Mon Jun 15 11:33:46 2026 +0200

Check LFH / CD encryption flag consistency

unz64local_CheckCurrentFileCoherencyHeader performs various consistency
checks on the values in the Local File Header and Central Directory.
Make it check the encryption flag as well.

Bug: 514461031
Change-Id: Ifaf8620c6e0c345118712bce6e1206bbb83b3a2d
Reviewed-on: https://chromium-review.googlesource.com/7942389

diff --git a/third_party/zlib/contrib/minizip/unzip.c b/third_party/zlib/contrib/minizip/unzip.c
index 0264f7ac570f7..4eb0de302cfdf 100644
--- a/third_party/zlib/contrib/minizip/unzip.c
+++ b/third_party/zlib/contrib/minizip/unzip.c
@@ -1439,6 +1439,8 @@ local int unz64local_CheckCurrentFileCoherencyHeader(unz64_s* s, uInt* piSizeVar
*/
if (unz64local_getShort(&s->z_filefunc, s->filestream,&uFlags) != UNZ_OK)
err=UNZ_ERRNO;
+ else if ((err==UNZ_OK) && ((uFlags & 1) != (s->cur_file_info.flag & 1)))
+ err=UNZ_BADZIPFILE; /* LFH/CD encryption flag mismatch */

if (unz64local_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK)
err=UNZ_ERRNO;
4 changes: 3 additions & 1 deletion lib/internal/quic/quic.js
Original file line number Diff line number Diff line change
Expand Up @@ -3586,7 +3586,9 @@ class QuicSession {

if (error) {
// If the session is still waiting to be closed, and error
// is specified, reject the closed promise.
// is specified, reject the closed promise. Mark it handled first
// (as with opened) to silence errors if it's not actually awaited.
markPromiseAsHandled(inner.pendingClose.promise);
inner.pendingClose.reject?.(error);
} else {
inner.pendingClose.resolve?.();
Expand Down
21 changes: 20 additions & 1 deletion lib/internal/vfs/providers/memory.js
Original file line number Diff line number Diff line change
Expand Up @@ -696,10 +696,13 @@ class MemoryProvider extends VirtualProvider {
const segments = this.#splitPath(normalized);
let current = this[kRoot];
let currentPath = '/';
let resolvedCurrentPath = '/';
let firstCreated;

for (const segment of segments) {
currentPath = pathPosix.join(currentPath, segment);
const resolvedPath = pathPosix.join(resolvedCurrentPath, segment);
this.#ensurePopulated(current, resolvedCurrentPath);
let entry = current.children.get(segment);
if (!entry) {
entry = new MemoryEntry(TYPE_DIR, { mode: options?.mode });
Expand All @@ -708,7 +711,23 @@ class MemoryProvider extends VirtualProvider {
if (firstCreated === undefined) {
firstCreated = currentPath;
}
} else if (!entry.isDirectory()) {
resolvedCurrentPath = resolvedPath;
} else if (entry.isSymbolicLink()) {
const targetPath = this.#resolveSymlinkTarget(resolvedPath, entry.target);
const result = this.#lookupEntry(targetPath, true, 0);
if (result.eloop) {
throw createELOOP('mkdir', path);
}
if (!result.entry) {
throw createENOENT('mkdir', path);
}
entry = result.entry;
resolvedCurrentPath = result.resolvedPath;
} else {
resolvedCurrentPath = resolvedPath;
}

if (!entry.isDirectory()) {
throw createENOTDIR('mkdir', path);
}
current = entry;
Expand Down
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.2.1-motley-3246f1b"
#define ZLIB_VERSION "1.3.2.1-motley-8b3aa8a"
#endif // SRC_ZLIB_VERSION_H_
47 changes: 47 additions & 0 deletions test/parallel/test-quic-session-unobserved-error-close.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Flags: --experimental-quic --no-warnings

// Regression test: destroying a session with an error while its `closed`
// promise is not being observed must NOT surface as an unhandled rejection.

import { hasQuic, skip, mustCall, mustNotCall } from '../common/index.mjs';
import { subscribe, unsubscribe } from 'node:diagnostics_channel';
import { setImmediate as tick } from 'node:timers/promises';

if (!hasQuic) {
skip('QUIC is not enabled');
}

const { listen, connect } = await import('../common/quic.mjs');

// Any unhandled rejection - e.g. an unobserved `closed` rejecting - fails.
process.on('unhandledRejection', mustNotCall('unexpected unhandled rejection'));

// We use the diagnostics channel to observe the error close without actually
// observing session.closed (not listening is the whole point of the test):
const serverErrored = Promise.withResolvers();
function onSessionError() {
unsubscribe('quic.session.error', onSessionError);
serverErrored.resolve();
}
subscribe('quic.session.error', onSessionError);

// The server session callback is left deliberately empty, so no response
// is sent and closed remains unobserved:
const serverEndpoint = await listen(mustCall());

const clientSession = await connect(serverEndpoint.address);
await clientSession.opened;

// Finish handshake before close:
await tick();

// Cleanly close from the client with an error code, so the server
// receives a peer error close:
await clientSession.close({ code: 1 });

// Wait until the server has processed the error close, plus another tick
// to ensure unobserved promise rejection doesn't fire anywhere:
await serverErrored.promise;
await tick();

await serverEndpoint.close();
60 changes: 59 additions & 1 deletion test/parallel/test-vfs-mkdir.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// mkdirSync / rmdirSync behaviour: return value, recursive option, mode
// option, error cases.

require('../common');
const common = require('../common');
const assert = require('assert');
const vfs = require('node:vfs');

Expand All @@ -17,6 +17,51 @@ const vfs = require('node:vfs');
assert.strictEqual(result, '/a/b');
}

// Recursive mkdir follows symlinked intermediate directories, but returns the
// path of the first created directory as requested by the caller.
{
const myVfs = vfs.create();
myVfs.mkdirSync('/target');
myVfs.symlinkSync('/target', '/link');

const result = myVfs.mkdirSync('/link/subdir/deep', { recursive: true });

assert.strictEqual(result, '/link/subdir');
assert.strictEqual(myVfs.existsSync('/target/subdir/deep'), true);
assert.strictEqual(myVfs.existsSync('/link/subdir/deep'), true);
}

// Recursive mkdir also resolves relative symlink targets from the symlink's
// resolved parent directory.
{
const myVfs = vfs.create();
myVfs.mkdirSync('/parent/target', { recursive: true });
myVfs.symlinkSync('target', '/parent/link');

myVfs.mkdirSync('/parent/link/subdir', { recursive: true });

assert.strictEqual(myVfs.existsSync('/parent/target/subdir'), true);
}

// Recursive mkdir through symlinks keeps native error behavior for bad
// intermediate targets.
{
const myVfs = vfs.create();
myVfs.symlinkSync('/missing', '/dangling');
assert.throws(
() => myVfs.mkdirSync('/dangling/subdir', { recursive: true }),
{ code: 'ENOENT' });
}

{
const myVfs = vfs.create();
myVfs.writeFileSync('/file', 'x');
myVfs.symlinkSync('/file', '/link');
assert.throws(
() => myVfs.mkdirSync('/link/subdir', { recursive: true }),
{ code: 'ENOTDIR' });
}

// mkdirSync with explicit mode (non-recursive)
{
const myVfs = vfs.create();
Expand Down Expand Up @@ -47,3 +92,16 @@ const vfs = require('node:vfs');
myVfs.writeFileSync('/d/x', '');
assert.throws(() => myVfs.rmdirSync('/d'), { code: 'ENOTEMPTY' });
}

// promises.mkdir uses the same recursive symlink handling.
(async () => {
const myVfs = vfs.create();
myVfs.mkdirSync('/target');
myVfs.symlinkSync('/target', '/link');

const result = await myVfs.promises.mkdir('/link/subdir/deep',
{ recursive: true });

assert.strictEqual(result, '/link/subdir');
assert.strictEqual(myVfs.existsSync('/target/subdir/deep'), true);
})().then(common.mustCall());
4 changes: 2 additions & 2 deletions tools/nix/pkgs.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
arg:
let
repo = "https://github.com/NixOS/nixpkgs";
rev = "89570f24e97e614aa34aa9ab1c927b6578a43775";
rev = "d33369954a67ae3322177dc9a3d564092912120c";
nixpkgs = import (builtins.fetchTarball {
url = "${repo}/archive/${rev}.tar.gz";
sha256 = "0jfrm4wdjfg8d45b4gnxrcwa8kzclv9qisbv68v19d6fd4mdgk0h";
sha256 = "0ffi2k8hllbgqw9vvdfaxw88qz53gl7myll4lwri6ynq5l0lnvbc";
}) arg;
in
nixpkgs
4 changes: 2 additions & 2 deletions tools/v8_gypfiles/v8.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -342,12 +342,12 @@
'<(V8_ROOT)/src/builtins/arm64/builtins-arm64.cc',
],
}],
['v8_target_arch=="riscv64" or v8_target_arch=="riscv64"', {
['v8_target_arch=="riscv64"', {
'sources': [
'<(V8_ROOT)/src/builtins/riscv/builtins-riscv.cc',
],
}],
['v8_target_arch=="loong64" or v8_target_arch=="loong64"', {
['v8_target_arch=="loong64"', {
'sources': [
'<(V8_ROOT)/src/builtins/loong64/builtins-loong64.cc',
],
Expand Down
Loading