mirror of
https://github.com/electron/electron.git
synced 2026-01-09 15:38:08 -05:00
* chore: upgrade to Node.js v20 * src: allow embedders to override NODE_MODULE_VERSION https://github.com/nodejs/node/pull/49279 * src: fix missing trailing , https://github.com/nodejs/node/pull/46909 * src,tools: initialize cppgc https://github.com/nodejs/node/pull/45704 * tools: allow passing absolute path of config.gypi in js2c https://github.com/nodejs/node/pull/49162 * tools: port js2c.py to C++ https://github.com/nodejs/node/pull/46997 * doc,lib: disambiguate the old term, NativeModule https://github.com/nodejs/node/pull/45673 * chore: fixup Node.js BSSL tests * https://github.com/nodejs/node/pull/49492 * https://github.com/nodejs/node/pull/44498 * deps: upgrade to libuv 1.45.0 https://github.com/nodejs/node/pull/48078 * deps: update V8 to 10.7 https://github.com/nodejs/node/pull/44741 * test: use gcUntil() in test-v8-serialize-leak https://github.com/nodejs/node/pull/49168 * module: make CJS load from ESM loader https://github.com/nodejs/node/pull/47999 * src: make BuiltinLoader threadsafe and non-global https://github.com/nodejs/node/pull/45942 * chore: address changes to CJS/ESM loading * module: make CJS load from ESM loader (https://github.com/nodejs/node/pull/47999) * lib: improve esm resolve performance (https://github.com/nodejs/node/pull/46652) * bootstrap: optimize modules loaded in the built-in snapshot https://github.com/nodejs/node/pull/45849 * test: mark test-runner-output as flaky https://github.com/nodejs/node/pull/49854 * lib: lazy-load deps in modules/run_main.js https://github.com/nodejs/node/pull/45849 * url: use private properties for brand check https://github.com/nodejs/node/pull/46904 * test: refactor `test-node-output-errors` https://github.com/nodejs/node/pull/48992 * assert: deprecate callTracker https://github.com/nodejs/node/pull/47740 * src: cast v8::Object::GetInternalField() return value to v8::Value https://github.com/nodejs/node/pull/48943 * test: adapt test-v8-stats for V8 update https://github.com/nodejs/node/pull/45230 * tls: ensure TLS Sockets are closed if the underlying wrap closes https://github.com/nodejs/node/pull/49327 * test: deflake test-tls-socket-close https://github.com/nodejs/node/pull/49575 * net: fix crash due to simultaneous close/shutdown on JS Stream Sockets https://github.com/nodejs/node/pull/49400 * net: use asserts in JS Socket Stream to catch races in future https://github.com/nodejs/node/pull/49400 * lib: fix BroadcastChannel initialization location https://github.com/nodejs/node/pull/46864 * src: create BaseObject with node::Realm https://github.com/nodejs/node/pull/44348 * src: implement DataQueue and non-memory resident Blob https://github.com/nodejs/node/pull/45258 * sea: add support for V8 bytecode-only caching https://github.com/nodejs/node/pull/48191 * chore: fixup patch indices * gyp: put filenames in variables https://github.com/nodejs/node/pull/46965 * build: modify js2c.py into GN executable * fix: (WIP) handle string replacement of fs -> original-fs * [v20.x] backport vm-related memory fixes https://github.com/nodejs/node/pull/49874 * src: make BuiltinLoader threadsafe and non-global https://github.com/nodejs/node/pull/45942 * src: avoid copying string in fs_permission https://github.com/nodejs/node/pull/47746 * look upon my works ye mighty and dispair * chore: patch cleanup * [api] Remove AllCan Read/Write https://chromium-review.googlesource.com/c/v8/v8/+/5006387 * fix: missing include for NODE_EXTERN * chore: fixup patch indices * fix: fail properly when js2c fails in Node.js * build: fix js2c root_gen_dir * fix: lib/fs.js -> lib/original-fs.js * build: fix original-fs file xforms * fixup! module: make CJS load from ESM loader * build: get rid of CppHeap for now * build: add patch to prevent extra fs lookup on esm load * build: greatly simplify js2c modifications Moves our original-fs modifications back into a super simple python script action, wires up the output of that action into our call to js2c * chore: update to handle moved internal/modules/helpers file * test: update @types/node test * feat: enable preventing cppgc heap creation * feat: optionally prevent calling V8::EnableWebAssemblyTrapHandler * fix: no cppgc initialization in the renderer * gyp: put filenames in variables https://github.com/nodejs/node/pull/46965 * test: disable single executable tests * fix: nan tests failing on node headers missing file * tls,http2: send fatal alert on ALPN mismatch https://github.com/nodejs/node/pull/44031 * test: disable snapshot tests * https://github.com/nodejs/node/pull/47887 * https://github.com/nodejs/node/pull/49684 * https://github.com/nodejs/node/pull/44193 * build: use deps/v8 for v8/tools Node.js hard depends on these in their builtins * test: fix edge snapshot stack traces https://github.com/nodejs/node/pull/49659 * build: remove js2c //base dep * build: use electron_js2c_toolchain to build node_js2c * fix: don't create SafeSet outside packageResolve Fixes failure in parallel/test-require-delete-array-iterator: === release test-require-delete-array-iterator === Path: parallel/test-require-delete-array-iterator node:internal/per_context/primordials:426 constructor(i) { super(i); } // eslint-disable-line no-useless-constructor ^ TypeError: object is not iterable (cannot read property Symbol(Symbol.iterator)) at new Set (<anonymous>) at new SafeSet (node:internal/per_context/primordials:426:22) * fix: failing crashReporter tests on Linux These were failing because our change from node::InitializeNodeWithArgs to node::InitializeOncePerProcess meant that we now inadvertently called PlatformInit, which reset signal handling. This meant that our intentional crash function ElectronBindings::Crash no longer worked and the renderer process no longer crashed when process.crash() was called. We don't want to use Node.js' default signal handling in the renderer process, so we disable it by passing kNoDefaultSignalHandling to node::InitializeOncePerProcess. * build: only create cppgc heap on non-32 bit platforms * chore: clean up util:CompileAndCall * src: fix compatility with upcoming V8 12.1 APIs https://github.com/nodejs/node/pull/50709 * fix: use thread_local BuiltinLoader * chore: fixup v8 patch indices --------- Co-authored-by: Keeley Hammond <vertedinde@electronjs.org> Co-authored-by: Samuel Attard <marshallofsound@electronjs.org>
156 lines
5.8 KiB
Diff
156 lines
5.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= <targos@protonmail.com>
|
|
Date: Thu, 28 Sep 2023 14:50:20 +0200
|
|
Subject: lib,test: do not hardcode Buffer.kMaxLength
|
|
|
|
V8 will soon support typed arrays as large as the maximum array buffer
|
|
length. This patch replaces hardcoded values related to
|
|
Buffer.kMaxLength with the actual constant.
|
|
It also fixes a test that was passing by accident.
|
|
|
|
Refs: https://github.com/v8/v8/commit/44b299590083b888637c79fb5632806e607ab861
|
|
PR-URL: https://github.com/nodejs/node/pull/49876
|
|
Reviewed-By: Richard Lau <rlau@redhat.com>
|
|
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
|
|
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
|
|
(cherry picked from commit a4fdb1abe0844d86b4cbfcc4051794656e7d746e)
|
|
|
|
diff --git a/lib/internal/blob.js b/lib/internal/blob.js
|
|
index d0e47c1a4397a875c937d43c3b72dbd1e1de35a7..400d2c5fd21bc962a8befc4d80527216baddd6d5 100644
|
|
--- a/lib/internal/blob.js
|
|
+++ b/lib/internal/blob.js
|
|
@@ -24,6 +24,9 @@ const {
|
|
concat,
|
|
getDataObject,
|
|
} = internalBinding('blob');
|
|
+const {
|
|
+ kMaxLength,
|
|
+} = internalBinding('buffer');
|
|
|
|
const {
|
|
TextDecoder,
|
|
@@ -62,7 +65,6 @@ const {
|
|
} = require('internal/errors');
|
|
|
|
const {
|
|
- isUint32,
|
|
validateDictionary,
|
|
} = require('internal/validators');
|
|
|
|
@@ -158,8 +160,8 @@ class Blob {
|
|
return src;
|
|
});
|
|
|
|
- if (!isUint32(length))
|
|
- throw new ERR_BUFFER_TOO_LARGE(0xFFFFFFFF);
|
|
+ if (length > kMaxLength)
|
|
+ throw new ERR_BUFFER_TOO_LARGE(kMaxLength);
|
|
|
|
this[kHandle] = _createBlob(sources_, length);
|
|
this[kLength] = length;
|
|
diff --git a/test/parallel/test-blob-buffer-too-large.js b/test/parallel/test-blob-buffer-too-large.js
|
|
index 2fd8b8754bd593a0da069044d33fcd6bba82f9c9..a9cf53b025bbff58a8d5783e4f807d79f5d68e2b 100644
|
|
--- a/test/parallel/test-blob-buffer-too-large.js
|
|
+++ b/test/parallel/test-blob-buffer-too-large.js
|
|
@@ -3,17 +3,17 @@
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
-const { Blob } = require('buffer');
|
|
+const { Blob, kMaxLength } = require('buffer');
|
|
|
|
if (common.isFreeBSD)
|
|
common.skip('Oversized buffer make the FreeBSD CI runner crash');
|
|
|
|
try {
|
|
- new Blob([new Uint8Array(0xffffffff), [1]]);
|
|
+ new Blob([new Uint8Array(kMaxLength), [1]]);
|
|
} catch (e) {
|
|
if (
|
|
e.message === 'Array buffer allocation failed' ||
|
|
- e.message === 'Invalid typed array length: 4294967295'
|
|
+ e.message === `Invalid typed array length: ${kMaxLength}`
|
|
) {
|
|
common.skip(
|
|
'Insufficient memory on this platform for oversized buffer test.'
|
|
diff --git a/test/parallel/test-buffer-alloc.js b/test/parallel/test-buffer-alloc.js
|
|
index c6b728027057ece38c2b7fcc6bf7b18b959125d2..aad9c6bcab69e971c02281928885d94aa21c8199 100644
|
|
--- a/test/parallel/test-buffer-alloc.js
|
|
+++ b/test/parallel/test-buffer-alloc.js
|
|
@@ -4,13 +4,16 @@ const common = require('../common');
|
|
const assert = require('assert');
|
|
const vm = require('vm');
|
|
|
|
-const SlowBuffer = require('buffer').SlowBuffer;
|
|
+const {
|
|
+ SlowBuffer,
|
|
+ kMaxLength,
|
|
+} = require('buffer');
|
|
|
|
// Verify the maximum Uint8Array size. There is no concrete limit by spec. The
|
|
// internal limits should be updated if this fails.
|
|
assert.throws(
|
|
- () => new Uint8Array(2 ** 32 + 1),
|
|
- { message: 'Invalid typed array length: 4294967297' }
|
|
+ () => new Uint8Array(kMaxLength + 1),
|
|
+ { message: `Invalid typed array length: ${kMaxLength + 1}` },
|
|
);
|
|
|
|
const b = Buffer.allocUnsafe(1024);
|
|
diff --git a/test/parallel/test-buffer-over-max-length.js b/test/parallel/test-buffer-over-max-length.js
|
|
index d2df358cc00ca4b238252d6d11bdad3b77fad114..f29d6b62d4aa408fb3a67ffe71b14436fbbff907 100644
|
|
--- a/test/parallel/test-buffer-over-max-length.js
|
|
+++ b/test/parallel/test-buffer-over-max-length.js
|
|
@@ -12,18 +12,8 @@ const bufferMaxSizeMsg = {
|
|
name: 'RangeError',
|
|
};
|
|
|
|
-assert.throws(() => Buffer((-1 >>> 0) + 2), bufferMaxSizeMsg);
|
|
-assert.throws(() => SlowBuffer((-1 >>> 0) + 2), bufferMaxSizeMsg);
|
|
-assert.throws(() => Buffer.alloc((-1 >>> 0) + 2), bufferMaxSizeMsg);
|
|
-assert.throws(() => Buffer.allocUnsafe((-1 >>> 0) + 2), bufferMaxSizeMsg);
|
|
-assert.throws(() => Buffer.allocUnsafeSlow((-1 >>> 0) + 2), bufferMaxSizeMsg);
|
|
-
|
|
assert.throws(() => Buffer(kMaxLength + 1), bufferMaxSizeMsg);
|
|
assert.throws(() => SlowBuffer(kMaxLength + 1), bufferMaxSizeMsg);
|
|
assert.throws(() => Buffer.alloc(kMaxLength + 1), bufferMaxSizeMsg);
|
|
assert.throws(() => Buffer.allocUnsafe(kMaxLength + 1), bufferMaxSizeMsg);
|
|
assert.throws(() => Buffer.allocUnsafeSlow(kMaxLength + 1), bufferMaxSizeMsg);
|
|
-
|
|
-// issue GH-4331
|
|
-assert.throws(() => Buffer.allocUnsafe(0x100000001), bufferMaxSizeMsg);
|
|
-assert.throws(() => Buffer.allocUnsafe(0xFFFFFFFFF), bufferMaxSizeMsg);
|
|
diff --git a/test/parallel/test-buffer-tostring-rangeerror.js b/test/parallel/test-buffer-tostring-rangeerror.js
|
|
index d2e1e0d6e46438f20d6b8f1196ebd936d4fa3436..0ebea759b5c42be0c294093256ea3cad7034a98b 100644
|
|
--- a/test/parallel/test-buffer-tostring-rangeerror.js
|
|
+++ b/test/parallel/test-buffer-tostring-rangeerror.js
|
|
@@ -1,17 +1,22 @@
|
|
'use strict';
|
|
require('../common');
|
|
|
|
-// This test ensures that Node.js throws a RangeError when trying to convert a
|
|
-// gigantic buffer into a string.
|
|
+// This test ensures that Node.js throws an Error when trying to convert a
|
|
+// large buffer into a string.
|
|
// Regression test for https://github.com/nodejs/node/issues/649.
|
|
|
|
const assert = require('assert');
|
|
-const SlowBuffer = require('buffer').SlowBuffer;
|
|
+const {
|
|
+ SlowBuffer,
|
|
+ constants: {
|
|
+ MAX_STRING_LENGTH,
|
|
+ },
|
|
+} = require('buffer');
|
|
|
|
-const len = 1422561062959;
|
|
+const len = MAX_STRING_LENGTH + 1;
|
|
const message = {
|
|
- code: 'ERR_OUT_OF_RANGE',
|
|
- name: 'RangeError',
|
|
+ code: 'ERR_STRING_TOO_LONG',
|
|
+ name: 'Error',
|
|
};
|
|
assert.throws(() => Buffer(len).toString('utf8'), message);
|
|
assert.throws(() => SlowBuffer(len).toString('utf8'), message);
|