diff --git a/DEPS b/DEPS index a6357d140169..10ae0bceca52 100644 --- a/DEPS +++ b/DEPS @@ -4,7 +4,7 @@ vars = { 'chromium_version': '114.0.5715.0', 'node_version': - 'v18.15.0', + 'v18.16.0', 'nan_version': '16fa32231e2ccd89d2804b3f765319128b20c4ac', 'squirrel.mac_version': diff --git a/patches/node/.patches b/patches/node/.patches index a9f117a41ac1..13b0ab7ad3b2 100644 --- a/patches/node/.patches +++ b/patches/node/.patches @@ -12,7 +12,6 @@ chore_add_context_to_context_aware_module_prevention.patch fix_handle_boringssl_and_openssl_incompatibilities.patch fix_crypto_tests_to_run_with_bssl.patch fix_account_for_debugger_agent_race_condition.patch -repl_fix_crash_when_sharedarraybuffer_disabled.patch fix_readbarrier_undefined_symbol_error_on_woa_arm64.patch fix_suppress_clang_-wdeprecated-declarations_in_libuv.patch fix_serdes_test.patch @@ -24,15 +23,13 @@ build_ensure_v8_pointer_compression_sandbox_is_enabled_on_64bit.patch build_ensure_native_module_compilation_fails_if_not_using_a_new.patch fix_override_createjob_in_node_platform.patch v8_api_advance_api_deprecation.patch -fixup_for_error_declaration_shadows_a_local_variable.patch fix_parallel_test-v8-stats.patch fix_expose_the_built-in_electron_module_via_the_esm_loader.patch api_pass_oomdetails_to_oomerrorcallback.patch fix_expose_lookupandcompile_with_parameters.patch fix_prevent_changing_functiontemplateinfo_after_publish.patch enable_crashpad_linux_node_processes.patch -allow_embedder_to_control_codegenerationfromstringscallback.patch -src_allow_optional_isolation_termination_in_node.patch test_mark_cpu_prof_tests_as_flaky_in_electron.patch -lib_fix_broadcastchannel_initialization_location.patch fix_adapt_debugger_tests_for_upstream_v8_changes.patch +fix_libc_buffer_overflow_in_string_view_ctor.patch +fix_preventing_potential_oob_in_ada_no_scheme_parsing.patch diff --git a/patches/node/allow_embedder_to_control_codegenerationfromstringscallback.patch b/patches/node/allow_embedder_to_control_codegenerationfromstringscallback.patch deleted file mode 100644 index c79deba359bc..000000000000 --- a/patches/node/allow_embedder_to_control_codegenerationfromstringscallback.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jeremy Rose -Date: Mon, 5 Dec 2022 14:28:40 -0800 -Subject: allow embedder to control CodeGenerationFromStringsCallback - -This is needed to blend Blink and Node's code generation policy. - -Upstreamed in https://github.com/nodejs/node/pull/46368. - -diff --git a/src/api/environment.cc b/src/api/environment.cc -index a994221445471b92d12ed9cb3bef9ffb70670ab6..d6c6fd9c257cb51ba387c4b4d07a24ff80f9f060 100644 ---- a/src/api/environment.cc -+++ b/src/api/environment.cc -@@ -268,11 +268,15 @@ void SetIsolateErrorHandlers(v8::Isolate* isolate, const IsolateSettings& s) { - void SetIsolateMiscHandlers(v8::Isolate* isolate, const IsolateSettings& s) { - isolate->SetMicrotasksPolicy(s.policy); - -+ // Allow the embedder first chance at policy decisions. -+ // This is particularly important for embedders that combine Node and Blink, -+ // as Blink must be able to make Content Security Policy-based decisions. - auto* allow_wasm_codegen_cb = s.allow_wasm_code_generation_callback ? - s.allow_wasm_code_generation_callback : AllowWasmCodeGenerationCallback; - isolate->SetAllowWasmCodeGenerationCallback(allow_wasm_codegen_cb); -- isolate->SetModifyCodeGenerationFromStringsCallback( -- ModifyCodeGenerationFromStrings); -+ auto* modify_code_generation_from_strings_callback = s.modify_code_generation_from_strings_callback ? -+ s.modify_code_generation_from_strings_callback : ModifyCodeGenerationFromStrings; -+ isolate->SetModifyCodeGenerationFromStringsCallback(modify_code_generation_from_strings_callback); - - Mutex::ScopedLock lock(node::per_process::cli_options_mutex); - if (per_process::cli_options->get_per_isolate_options() -diff --git a/src/node.h b/src/node.h -index 03f55b0a1853c055eb6c709a8e7916c2a95672d3..47ac8c24ef5e26822f694b583767e850fc5f7d96 100644 ---- a/src/node.h -+++ b/src/node.h -@@ -463,6 +463,8 @@ struct IsolateSettings { - v8::PromiseRejectCallback promise_reject_callback = nullptr; - v8::AllowWasmCodeGenerationCallback - allow_wasm_code_generation_callback = nullptr; -+ v8::ModifyCodeGenerationFromStringsCallback2 -+ modify_code_generation_from_strings_callback = nullptr; - }; - - // Overriding IsolateSettings may produce unexpected behavior diff --git a/patches/node/api_pass_oomdetails_to_oomerrorcallback.patch b/patches/node/api_pass_oomdetails_to_oomerrorcallback.patch index 8aabd90dee01..8e316f8f3aa7 100644 --- a/patches/node/api_pass_oomdetails_to_oomerrorcallback.patch +++ b/patches/node/api_pass_oomdetails_to_oomerrorcallback.patch @@ -8,10 +8,10 @@ Introduced in https://chromium-review.googlesource.com/c/v8/v8/+/3647827. This patch can be removed when Electron updates to Node.js v20. diff --git a/src/node_errors.cc b/src/node_errors.cc -index 9f620154ce3696cff90bf308da934147319b1096..806d9700ca4b5faf46042814c0e2ce212945bece 100644 +index 2dc9e085269222c70902698020fc5c7b1af2f004..655f54e369c35efefa75c69cc57776249405dc76 100644 --- a/src/node_errors.cc +++ b/src/node_errors.cc -@@ -495,9 +495,9 @@ void OnFatalError(const char* location, const char* message) { +@@ -527,9 +527,9 @@ void OnFatalError(const char* location, const char* message) { ABORT(); } diff --git a/patches/node/build_add_gn_build_files.patch b/patches/node/build_add_gn_build_files.patch index 1225b2e42dad..923e5fc987c6 100644 --- a/patches/node/build_add_gn_build_files.patch +++ b/patches/node/build_add_gn_build_files.patch @@ -7,10 +7,10 @@ This adds GN build files for Node, so we don't have to build with GYP. diff --git a/BUILD.gn b/BUILD.gn new file mode 100644 -index 0000000000000000000000000000000000000000..5e8577795316984f3073204523d82a17f44b0f88 +index 0000000000000000000000000000000000000000..a3e4599c21f2faa92a0dca47b1e0b4e836bb475d --- /dev/null +++ b/BUILD.gn -@@ -0,0 +1,439 @@ +@@ -0,0 +1,443 @@ +import("//v8/gni/v8.gni") +import("node.gni") + @@ -223,6 +223,7 @@ index 0000000000000000000000000000000000000000..5e8577795316984f3073204523d82a17 + deps = [ + ":node_js2c", + "deps/googletest:gtest", ++ "deps/ada", + "deps/base64", + "deps/simdutf", + "deps/uvwasi", @@ -248,7 +249,10 @@ index 0000000000000000000000000000000000000000..5e8577795316984f3073204523d82a17 + ] + configs += [ ":node_internal_config" ] + public_configs = [ ":node_lib_config" ] -+ include_dirs = [ "src" ] ++ include_dirs = [ ++ "src", ++ "deps/postject" ++ ] + libs = [] + if (use_system_llhttp) { + libs += [ "llhttp" ] @@ -450,6 +454,40 @@ index 0000000000000000000000000000000000000000..5e8577795316984f3073204523d82a17 + ":tar_headers", + ] +} +diff --git a/deps/ada/BUILD.gn b/deps/ada/BUILD.gn +new file mode 100644 +index 0000000000000000000000000000000000000000..a564653c3f05608d59fed5aa071d63b81f4e0e42 +--- /dev/null ++++ b/deps/ada/BUILD.gn +@@ -0,0 +1,28 @@ ++import("//v8/gni/v8.gni") ++ ++config("ada_config") { ++ include_dirs = [ "." ] ++} ++ ++static_library("ada") { ++ include_dirs = [ "." ] ++ sources = [ "ada.cpp" ] ++ ++ public_configs = [ ":ada_config" ] ++ ++ defines = [] ++ deps = [] ++ ++ if (v8_enable_i18n_support) { ++ deps += [ ++ "//third_party/icu:icui18n", ++ "//third_party/icu:icuuc", ++ ] ++ ++ if (is_win) { ++ deps += [ "//third_party/icu:icudata" ] ++ } ++ } else { ++ defines += [ "ADA_HAS_ICU=0" ] ++ } ++} diff --git a/deps/base64/BUILD.gn b/deps/base64/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..694e1991bb11c9ea85fcc69a0e06265d4b0c5aab @@ -1220,10 +1258,10 @@ index 0000000000000000000000000000000000000000..2c9d2826c85bdd033f1df1d6188df636 +} diff --git a/filenames.json b/filenames.json new file mode 100644 -index 0000000000000000000000000000000000000000..71173dd5c0958d473972dfb397f230df6309b413 +index 0000000000000000000000000000000000000000..bfed2576bda1371c35533bcf50888f84d82b57f3 --- /dev/null +++ b/filenames.json -@@ -0,0 +1,659 @@ +@@ -0,0 +1,663 @@ +// This file is automatically generated by generate_gn_filenames_json.py +// DO NOT EDIT +{ @@ -1478,6 +1516,7 @@ index 0000000000000000000000000000000000000000..71173dd5c0958d473972dfb397f230df + "lib/internal/main/prof_process.js", + "lib/internal/main/repl.js", + "lib/internal/main/run_main_module.js", ++ "lib/internal/main/single_executable_application.js", + "lib/internal/main/test_runner.js", + "lib/internal/main/watch_mode.js", + "lib/internal/main/worker_thread.js", @@ -1498,6 +1537,7 @@ index 0000000000000000000000000000000000000000..71173dd5c0958d473972dfb397f230df + "lib/internal/modules/esm/package_config.js", + "lib/internal/modules/esm/resolve.js", + "lib/internal/modules/esm/translators.js", ++ "lib/internal/modules/esm/utils.js", + "lib/internal/modules/package_json_reader.js", + "lib/internal/modules/run_main.js", + "lib/internal/net.js", @@ -1731,6 +1771,7 @@ index 0000000000000000000000000000000000000000..71173dd5c0958d473972dfb397f230df + "src/node_report.cc", + "src/node_report_module.cc", + "src/node_report_utils.cc", ++ "src/node_sea.cc", + "src/node_serdes.cc", + "src/node_shadow_realm.cc", + "src/node_snapshotable.cc", @@ -1741,7 +1782,6 @@ index 0000000000000000000000000000000000000000..71173dd5c0958d473972dfb397f230df + "src/node_trace_events.cc", + "src/node_types.cc", + "src/node_url.cc", -+ "src/node_url_tables.cc", + "src/node_util.cc", + "src/node_v8.cc", + "src/node_wasi.cc", @@ -1840,6 +1880,7 @@ index 0000000000000000000000000000000000000000..71173dd5c0958d473972dfb397f230df + "src/node_report.h", + "src/node_revert.h", + "src/node_root_certs.h", ++ "src/node_sea.h", + "src/node_shadow_realm.h", + "src/node_snapshotable.h", + "src/node_snapshot_builder.h", @@ -1880,7 +1921,8 @@ index 0000000000000000000000000000000000000000..71173dd5c0958d473972dfb397f230df + "src/udp_wrap.h", + "src/util.h", + "src/util-inl.h", -+ "//v8/include/v8.h" ++ "//v8/include/v8.h", ++ "deps/postject/postject-api.h" + ] +} diff --git a/node.gni b/node.gni @@ -1918,12 +1960,25 @@ index 0000000000000000000000000000000000000000..9b1a4048a4a64c36d88de0bbe1a548c9 + args += invoker.args + } +} +diff --git a/node.gyp b/node.gyp +index cf52281bb4479ba20fbe852518edadc2185f0dae..81254f1d4fff9be925ecbb85fb0811c0909900dd 100644 +--- a/node.gyp ++++ b/node.gyp +@@ -687,7 +687,7 @@ + 'src/util-inl.h', + # Dependency headers + 'deps/v8/include/v8.h', +- 'deps/postject/postject-api.h' ++ 'deps/postject/postject-api.h', + # javascript files to make for an even more pleasant IDE experience + '<@(library_files)', + '<@(deps_files)', diff --git a/src/inspector/BUILD.gn b/src/inspector/BUILD.gn new file mode 100644 -index 0000000000000000000000000000000000000000..d1d6b51e8c0c5bc6a5d09e217eb3048361d9d591 +index 0000000000000000000000000000000000000000..4ab828dcbf322a9e28674e48c4a6868bd1321be2 --- /dev/null +++ b/src/inspector/BUILD.gn -@@ -0,0 +1,199 @@ +@@ -0,0 +1,200 @@ +import("//v8/gni/v8.gni") + +inspector_protocol_dir = "../../tools/inspector_protocol" @@ -1983,6 +2038,7 @@ index 0000000000000000000000000000000000000000..d1d6b51e8c0c5bc6a5d09e217eb30483 + ":protocol_generated_sources", + ":v8_inspector_compress_protocol_json", + "../../deps/uv", ++ "../../deps/simdutf", + "//third_party/icu:icuuc", + ] + configs += [ "../..:node_internal_config" ] @@ -2124,7 +2180,7 @@ index 0000000000000000000000000000000000000000..d1d6b51e8c0c5bc6a5d09e217eb30483 + args = rebase_path(inputs + outputs, root_build_dir) +} diff --git a/src/node_version.h b/src/node_version.h -index ee035efadf123464a7b4696a6351364a642cd947..afb9c47cc9324a6197a66e58bc59d40afc37dcf8 100644 +index cfab30173a4311582b1ebdc5a1b84b37117a8e69..c254fe22f9e2bc0f1746e773f7ecb0d1db31294b 100644 --- a/src/node_version.h +++ b/src/node_version.h @@ -89,7 +89,10 @@ @@ -2257,7 +2313,7 @@ index 0000000000000000000000000000000000000000..2a92eccfa582df361f2a889c0d9b32c1 + + out_file.writelines(new_contents) diff --git a/tools/install.py b/tools/install.py -index 9d5f4a48bca2c926b3ffb3c51c070222d4f7ce7b..c9ea9f67d3ccb213db3a5d149f0458987e855c08 100755 +index f13f2ecd662a5fb985839b394b45319c091b56d4..21bc48324946d52ed2b1c9eec35c1fcd4c536570 100755 --- a/tools/install.py +++ b/tools/install.py @@ -202,60 +202,74 @@ def files(action): @@ -2389,7 +2445,7 @@ index 9d5f4a48bca2c926b3ffb3c51c070222d4f7ce7b..c9ea9f67d3ccb213db3a5d149f045898 action(files_arg, dest) @@ -282,7 +296,7 @@ def headers(action): - if sys.platform.startswith('aix'): + if sys.platform.startswith('aix') or sys.platform == "os400": action(['out/Release/node.exp'], 'include/node/') - subdir_files('deps/v8/include', 'include/node/', wanted_v8_headers) @@ -2398,7 +2454,7 @@ index 9d5f4a48bca2c926b3ffb3c51c070222d4f7ce7b..c9ea9f67d3ccb213db3a5d149f045898 if 'false' == variables.get('node_shared_libuv'): subdir_files('deps/uv/include', 'include/node/', action) diff --git a/tools/js2c.py b/tools/js2c.py -index e295949a18508d7989f0925093a9dd6a284fecd6..8ba46c5d78c5c86d9f7b8b6972f3febbe87de61e 100755 +index f9c202e861b986e3171aa21079c3b29f51fe0398..ef24c4de0aaa2cd5f3c06e5bd8dd90de2b30ffcb 100755 --- a/tools/js2c.py +++ b/tools/js2c.py @@ -131,6 +131,14 @@ def NormalizeFileName(filename): diff --git a/patches/node/build_ensure_native_module_compilation_fails_if_not_using_a_new.patch b/patches/node/build_ensure_native_module_compilation_fails_if_not_using_a_new.patch index 38fb39a037ac..5e45b90c6690 100644 --- a/patches/node/build_ensure_native_module_compilation_fails_if_not_using_a_new.patch +++ b/patches/node/build_ensure_native_module_compilation_fails_if_not_using_a_new.patch @@ -7,7 +7,7 @@ Subject: build: ensure native module compilation fails if not using a new This should not be upstreamed, it is a quality-of-life patch for downstream module builders. diff --git a/common.gypi b/common.gypi -index 528ae2c370bc41fd245daea33ff8114cee68fce9..d56ed716c3245c9f89c750df232639318927749b 100644 +index f3e0047fea1319034bf8b05b8d54d8a4ef181b4b..be0289ea7df50d7c2cb002c6343b75014729c923 100644 --- a/common.gypi +++ b/common.gypi @@ -79,6 +79,8 @@ @@ -40,10 +40,10 @@ index 528ae2c370bc41fd245daea33ff8114cee68fce9..d56ed716c3245c9f89c750df23263931 'defines': [ 'V8_COMPRESS_POINTERS', diff --git a/configure.py b/configure.py -index bfa20f5fc7a64b30b464327f4086a027e9a23359..f9d849260c3d7b1368d375125ae587eaa396c49e 100755 +index 03ccbae0a1a837a382b98b828990d5a511f7a9d7..b5c747971a10b549007a8a3247aa5bd8058f311f 100755 --- a/configure.py +++ b/configure.py -@@ -1517,6 +1517,7 @@ def configure_library(lib, output, pkgname=None): +@@ -1529,6 +1529,7 @@ def configure_library(lib, output, pkgname=None): def configure_v8(o): @@ -52,7 +52,7 @@ index bfa20f5fc7a64b30b464327f4086a027e9a23359..f9d849260c3d7b1368d375125ae587ea o['variables']['v8_enable_javascript_promise_hooks'] = 1 o['variables']['v8_enable_lite_mode'] = 1 if options.v8_lite_mode else 0 diff --git a/src/node.h b/src/node.h -index 173e0bc669a2fd90e764da72e09003f4c7311fd7..03f55b0a1853c055eb6c709a8e7916c2a95672d3 100644 +index 4b9b416e77b07407eae7b9587705b74ad3e6f211..deefda5c684c062f3c707fbdee30878a74d5dbb0 100644 --- a/src/node.h +++ b/src/node.h @@ -22,6 +22,12 @@ diff --git a/patches/node/build_ensure_v8_pointer_compression_sandbox_is_enabled_on_64bit.patch b/patches/node/build_ensure_v8_pointer_compression_sandbox_is_enabled_on_64bit.patch index db5c2b8d4631..e0804226ebc8 100644 --- a/patches/node/build_ensure_v8_pointer_compression_sandbox_is_enabled_on_64bit.patch +++ b/patches/node/build_ensure_v8_pointer_compression_sandbox_is_enabled_on_64bit.patch @@ -8,7 +8,7 @@ Aligns common.gypi with the current build flag state of //v8. Specifically enables `V8_ENABLE_SANDBOX`, `V8_SANDBOXED_POINTERS`, `V8_COMPRESS_POINTERS` and `V8_COMPRESS_POINTERS_IN_SHARED_CAGE`. diff --git a/common.gypi b/common.gypi -index 497a73ed8a7515292eb65435b9b8a44dcaa57899..528ae2c370bc41fd245daea33ff8114cee68fce9 100644 +index 543ede0020fd79251bdd9eac897d9a0e330ef239..f3e0047fea1319034bf8b05b8d54d8a4ef181b4b 100644 --- a/common.gypi +++ b/common.gypi @@ -65,6 +65,7 @@ @@ -42,10 +42,10 @@ index 497a73ed8a7515292eb65435b9b8a44dcaa57899..528ae2c370bc41fd245daea33ff8114c 'defines': ['V8_31BIT_SMIS_ON_64BIT_ARCH'], }], diff --git a/configure.py b/configure.py -index 62c01aaf6a386d24e82289554520140f03699c95..bfa20f5fc7a64b30b464327f4086a027e9a23359 100755 +index 40e0395ebd2c3cbcff587294bf9f1646dcab21aa..03ccbae0a1a837a382b98b828990d5a511f7a9d7 100755 --- a/configure.py +++ b/configure.py -@@ -1530,6 +1530,7 @@ def configure_v8(o): +@@ -1542,6 +1542,7 @@ def configure_v8(o): o['variables']['v8_use_siphash'] = 0 if options.without_siphash else 1 o['variables']['v8_enable_pointer_compression'] = 1 if options.enable_pointer_compression else 0 o['variables']['v8_enable_31bit_smis_on_64bit_arch'] = 1 if options.enable_pointer_compression else 0 diff --git a/patches/node/build_modify_js2c_py_to_allow_injection_of_original-fs_and_custom_embedder_js.patch b/patches/node/build_modify_js2c_py_to_allow_injection_of_original-fs_and_custom_embedder_js.patch index cb8f64f52d67..952d10146559 100644 --- a/patches/node/build_modify_js2c_py_to_allow_injection_of_original-fs_and_custom_embedder_js.patch +++ b/patches/node/build_modify_js2c_py_to_allow_injection_of_original-fs_and_custom_embedder_js.patch @@ -14,7 +14,7 @@ renderer/browser/worker/sandboxed bootstrap scripts). These are loaded through LoadEmbedderJavaScriptSource() diff --git a/lib/internal/fs/watchers.js b/lib/internal/fs/watchers.js -index bc4555584ab1f97806a1e9cd17085a2488320908..b17dbf2a98c9f4b14fea60c87f05afcee6ec54fb 100644 +index ce885c154c81c5703365fa34957697698da9aff6..229b0d522aeee3632145c86715bea1394d496bc4 100644 --- a/lib/internal/fs/watchers.js +++ b/lib/internal/fs/watchers.js @@ -293,11 +293,13 @@ function emitCloseNT(self) { @@ -24,7 +24,7 @@ index bc4555584ab1f97806a1e9cd17085a2488320908..b17dbf2a98c9f4b14fea60c87f05afce -ObjectDefineProperty(FSEvent.prototype, 'owner', { - __proto__: null, - get() { return this[owner_symbol]; }, -- set(v) { return this[owner_symbol] = v; } +- set(v) { return this[owner_symbol] = v; }, -}); +if (!'owner' in FSEvent.prototype) { + ObjectDefineProperty(FSEvent.prototype, 'owner', { @@ -61,7 +61,7 @@ index 90b158b84bb2a66781cf92f5b4c1a64f9e2ee651..8d9f7c409659a30747e5feeac6cfec42 std::vector GetBuiltinIds(); diff --git a/tools/js2c.py b/tools/js2c.py -index 8ba46c5d78c5c86d9f7b8b6972f3febbe87de61e..38057495e04eba46ca87f6a0ea607f0fff46846e 100755 +index ef24c4de0aaa2cd5f3c06e5bd8dd90de2b30ffcb..ece70a8d7a1fdca051d4b821ba114be54bd34e4e 100755 --- a/tools/js2c.py +++ b/tools/js2c.py @@ -39,6 +39,8 @@ import codecs diff --git a/patches/node/chore_add_context_to_context_aware_module_prevention.patch b/patches/node/chore_add_context_to_context_aware_module_prevention.patch index c443557dc2f3..a2884b203966 100644 --- a/patches/node/chore_add_context_to_context_aware_module_prevention.patch +++ b/patches/node/chore_add_context_to_context_aware_module_prevention.patch @@ -8,7 +8,7 @@ modules from being used in the renderer process. This should be upstreamed as a customizable error message. diff --git a/src/node_binding.cc b/src/node_binding.cc -index 175d0bee02d3592891f671533857b737057ab684..cf1cbcd54448754c7199a128b5447945aecf3e92 100644 +index 5093c3e53cee6d0ad9a9100b487549c3b4e7ae46..3e7b796fe5d285289e409985a5dba77b0d230910 100644 --- a/src/node_binding.cc +++ b/src/node_binding.cc @@ -4,6 +4,7 @@ @@ -19,7 +19,7 @@ index 175d0bee02d3592891f671533857b737057ab684..cf1cbcd54448754c7199a128b5447945 #include "util.h" #include -@@ -474,7 +475,12 @@ void DLOpen(const FunctionCallbackInfo& args) { +@@ -475,7 +476,12 @@ void DLOpen(const FunctionCallbackInfo& args) { if (mp->nm_context_register_func == nullptr) { if (env->force_context_aware()) { dlib->Close(); diff --git a/patches/node/chore_allow_the_node_entrypoint_to_be_a_builtin_module.patch b/patches/node/chore_allow_the_node_entrypoint_to_be_a_builtin_module.patch index 164dcf42e6cf..817286860330 100644 --- a/patches/node/chore_allow_the_node_entrypoint_to_be_a_builtin_module.patch +++ b/patches/node/chore_allow_the_node_entrypoint_to_be_a_builtin_module.patch @@ -8,7 +8,7 @@ they use themselves as the entry point. We should try to upstream some form of this. diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js -index c19cd5e5d8a818c52406c78b95d96bae1b1f41bd..88df0c4b6f995c993c330963ff0c730e00c5b8ec 100644 +index f2e8dc028b8b60108f1aa2301d65001b5a3774c7..9bcb56adb6d0a8f0e4462226398687da6a5b5629 100644 --- a/lib/internal/modules/cjs/loader.js +++ b/lib/internal/modules/cjs/loader.js @@ -1228,6 +1228,13 @@ Module.prototype._compile = function(content, filename) { @@ -26,7 +26,7 @@ index c19cd5e5d8a818c52406c78b95d96bae1b1f41bd..88df0c4b6f995c993c330963ff0c730e try { resolvedArgv = Module._resolveFilename(process.argv[1], null, false); diff --git a/lib/internal/process/pre_execution.js b/lib/internal/process/pre_execution.js -index 158daaf93446d99d21dd001a3ab614b1036c0b02..51e50801a92997797b6cb3f0ae91a1945a551c0f 100644 +index f91a32c0348f805d01d9c198c39cff4c5c72c88b..421b0ada67e281b4d269c7d3154e42f63e1e2cc7 100644 --- a/lib/internal/process/pre_execution.js +++ b/lib/internal/process/pre_execution.js @@ -150,11 +150,13 @@ function patchProcessObject(expandArgv1) { diff --git a/patches/node/enable_crashpad_linux_node_processes.patch b/patches/node/enable_crashpad_linux_node_processes.patch index 0a5b57bcc91c..92b3bddda966 100644 --- a/patches/node/enable_crashpad_linux_node_processes.patch +++ b/patches/node/enable_crashpad_linux_node_processes.patch @@ -8,7 +8,7 @@ to child processes spawned with `ELECTRON_RUN_AS_NODE` which is used by the crashpad client to connect with the handler process. diff --git a/lib/child_process.js b/lib/child_process.js -index 1bc5f92181a48e1ee37e59220ad11a755b20c9f4..d9d6a39f113151a489a3521ca8512f8ea5b1843c 100644 +index 07ad7906a7be156926d0c770c3d766c1a411203b..31061418c21d3764685110e827fc5ff536c74430 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -60,6 +60,7 @@ let debug = require('internal/util/debuglog').debuglog( diff --git a/patches/node/expose_get_builtin_module_function.patch b/patches/node/expose_get_builtin_module_function.patch index 4a9960673784..508edc68b35b 100644 --- a/patches/node/expose_get_builtin_module_function.patch +++ b/patches/node/expose_get_builtin_module_function.patch @@ -9,10 +9,10 @@ modules to sandboxed renderers. TODO(codebytere): remove and replace with a public facing API. diff --git a/src/node_binding.cc b/src/node_binding.cc -index c7ae1c26fe2bbade7c5b3ffdb2d30efcf8551cb9..175d0bee02d3592891f671533857b737057ab684 100644 +index 60b5eea61cf05344de9862a028165fecdb63fd35..5093c3e53cee6d0ad9a9100b487549c3b4e7ae46 100644 --- a/src/node_binding.cc +++ b/src/node_binding.cc -@@ -608,6 +608,10 @@ void GetInternalBinding(const FunctionCallbackInfo& args) { +@@ -609,6 +609,10 @@ void GetInternalBinding(const FunctionCallbackInfo& args) { args.GetReturnValue().Set(exports); } diff --git a/patches/node/feat_add_knostartdebugsignalhandler_to_environment_to_prevent.patch b/patches/node/feat_add_knostartdebugsignalhandler_to_environment_to_prevent.patch index 46941e5cbe67..9b40a3eee524 100644 --- a/patches/node/feat_add_knostartdebugsignalhandler_to_environment_to_prevent.patch +++ b/patches/node/feat_add_knostartdebugsignalhandler_to_environment_to_prevent.patch @@ -22,7 +22,7 @@ index bea695bd8c92d44cb9526f347a9464549155ed85..0cbd1b25c107b5deba5fdd14551cc641 // configure --no-browser-globals #ifdef NODE_NO_BROWSER_GLOBALS diff --git a/src/env.h b/src/env.h -index 673581fd0e2ef91886fa5e6be6523a2394df6db1..562610e6827d8302f146b81d599dd366ba25cd74 100644 +index 82f2dd1689114ec9c89fa32130985f0e9e78cc5f..4cb02112598459ea78a4b7b683ddd57e21ecb4c4 100644 --- a/src/env.h +++ b/src/env.h @@ -767,6 +767,7 @@ class Environment : public MemoryRetainer { @@ -34,10 +34,10 @@ index 673581fd0e2ef91886fa5e6be6523a2394df6db1..562610e6827d8302f146b81d599dd366 inline uint64_t thread_id() const; inline worker::Worker* worker_context() const; diff --git a/src/inspector_agent.cc b/src/inspector_agent.cc -index 91e7beeaa0976059e6dac239e489d10ada558db4..1abf6801e0544b14dd26f0b96536bd78c5b01679 100644 +index 214f992c9d015593ccdecd6eff0af4d960eccfbb..e5307b529c88d0e4db7fd7c6bd1b032d219b8c31 100644 --- a/src/inspector_agent.cc +++ b/src/inspector_agent.cc -@@ -692,8 +692,10 @@ bool Agent::Start(const std::string& path, +@@ -693,8 +693,10 @@ bool Agent::Start(const std::string& path, StartIoThreadAsyncCallback)); uv_unref(reinterpret_cast(&start_io_thread_async)); start_io_thread_async.data = this; @@ -51,10 +51,10 @@ index 91e7beeaa0976059e6dac239e489d10ada558db4..1abf6801e0544b14dd26f0b96536bd78 parent_env_->AddCleanupHook([](void* data) { Environment* env = static_cast(data); diff --git a/src/node.h b/src/node.h -index 9579b04472350fca5b5dbce354d373b50f873972..173e0bc669a2fd90e764da72e09003f4c7311fd7 100644 +index 8314edbc82971148310c5c99e5a4b18dffa14e51..4b9b416e77b07407eae7b9587705b74ad3e6f211 100644 --- a/src/node.h +++ b/src/node.h -@@ -546,7 +546,11 @@ enum Flags : uint64_t { +@@ -559,7 +559,11 @@ enum Flags : uint64_t { // This control is needed by embedders who may not want to initialize the V8 // inspector in situations where one has already been created, // e.g. Blink's in Chromium. diff --git a/patches/node/feat_initialize_asar_support.patch b/patches/node/feat_initialize_asar_support.patch index 95ee321fce91..fede0b77ac3f 100644 --- a/patches/node/feat_initialize_asar_support.patch +++ b/patches/node/feat_initialize_asar_support.patch @@ -6,7 +6,7 @@ Subject: feat: initialize asar support This patch initializes asar support in Node.js. diff --git a/lib/internal/process/pre_execution.js b/lib/internal/process/pre_execution.js -index 44a9183d77614c55246a513ec8d47c3f5ec6e41b..158daaf93446d99d21dd001a3ab614b1036c0b02 100644 +index a4cc80d48064fe4f58edf569de4ea962cecb4540..f91a32c0348f805d01d9c198c39cff4c5c72c88b 100644 --- a/lib/internal/process/pre_execution.js +++ b/lib/internal/process/pre_execution.js @@ -118,12 +118,17 @@ function setupUserModules() { diff --git a/patches/node/fix_add_default_values_for_variables_in_common_gypi.patch b/patches/node/fix_add_default_values_for_variables_in_common_gypi.patch index df21e5ba9c34..bac54933dbff 100644 --- a/patches/node/fix_add_default_values_for_variables_in_common_gypi.patch +++ b/patches/node/fix_add_default_values_for_variables_in_common_gypi.patch @@ -7,7 +7,7 @@ common.gypi is a file that's included in the node header bundle, despite the fact that we do not build node with gyp. diff --git a/common.gypi b/common.gypi -index 782c871cffe4538385b1322a5233fa5d527d20a4..497a73ed8a7515292eb65435b9b8a44dcaa57899 100644 +index 42879b1e6bafb3d4bc8f298113d09c37930756ea..543ede0020fd79251bdd9eac897d9a0e330ef239 100644 --- a/common.gypi +++ b/common.gypi @@ -80,6 +80,23 @@ diff --git a/patches/node/fix_expose_the_built-in_electron_module_via_the_esm_loader.patch b/patches/node/fix_expose_the_built-in_electron_module_via_the_esm_loader.patch index 5edead64e084..b84b765d1c61 100644 --- a/patches/node/fix_expose_the_built-in_electron_module_via_the_esm_loader.patch +++ b/patches/node/fix_expose_the_built-in_electron_module_via_the_esm_loader.patch @@ -6,7 +6,7 @@ Subject: fix: expose the built-in electron module via the ESM loader This allows usage of `import { app } from 'electron'` and `import('electron')` natively in the browser + non-sandboxed renderer diff --git a/lib/internal/modules/esm/get_format.js b/lib/internal/modules/esm/get_format.js -index a7329d279bb07542d3f4027e0c8e2b035d493e5b..5cff70923b4ea7a4df918b2d3d1fbc7106159218 100644 +index eb5f0be49395b0192f18738d549241ae98793df7..522fd5cc6bea3e7fe4089eb25d64d65d2e8784ca 100644 --- a/lib/internal/modules/esm/get_format.js +++ b/lib/internal/modules/esm/get_format.js @@ -30,6 +30,7 @@ const protocolHandlers = { @@ -18,7 +18,7 @@ index a7329d279bb07542d3f4027e0c8e2b035d493e5b..5cff70923b4ea7a4df918b2d3d1fbc71 /** diff --git a/lib/internal/modules/esm/resolve.js b/lib/internal/modules/esm/resolve.js -index 646b12382f6ebd073fe5968f8c1c0f36dbc64eac..15415e0652864d059390bc7383e073c86f5d0c03 100644 +index fd7d2feada9bbbba589fe89230e45954fa2dd3be..3c9b1ad93f2c6b5fde5e9ed2a8bf1dc01d94a8de 100644 --- a/lib/internal/modules/esm/resolve.js +++ b/lib/internal/modules/esm/resolve.js @@ -824,6 +824,8 @@ function parsePackageName(specifier, base) { @@ -51,7 +51,7 @@ index 646b12382f6ebd073fe5968f8c1c0f36dbc64eac..15415e0652864d059390bc7383e073c8 } } diff --git a/lib/internal/modules/esm/translators.js b/lib/internal/modules/esm/translators.js -index 6f25b2e67ab77613c6ed63c227bb875d5461f45f..010fa8f78a21a8146879849e2e887332e2694e51 100644 +index a425749e82acd7593c9fb1ceffedc119a4e416f2..1ceb89da21610c703f4a18be5888373c7feaa370 100644 --- a/lib/internal/modules/esm/translators.js +++ b/lib/internal/modules/esm/translators.js @@ -154,7 +154,7 @@ translators.set('commonjs', async function commonjsStrategy(url, source, @@ -77,10 +77,10 @@ index 6f25b2e67ab77613c6ed63c227bb875d5461f45f..010fa8f78a21a8146879849e2e887332 // We might trigger a getter -> dont fail. let value; diff --git a/lib/internal/url.js b/lib/internal/url.js -index ae133b02e20fa183d610da97ae0a50522318b4fc..433b51a6fec589f8c1fd2791fd685b3b4964cada 100644 +index 7b2e0b4ffa6cc71b78dd1a1f64f7f491a6669383..41327e0f33828b1a3f276c9054293d89a7956e1d 100644 --- a/lib/internal/url.js +++ b/lib/internal/url.js -@@ -1489,6 +1489,8 @@ function fileURLToPath(path) { +@@ -1221,6 +1221,8 @@ function fileURLToPath(path) { path = new URL(path); else if (!isURLInstance(path)) throw new ERR_INVALID_ARG_TYPE('path', ['string', 'URL'], path); diff --git a/patches/node/fix_expose_tracing_agent_and_use_tracing_tracingcontroller_instead.patch b/patches/node/fix_expose_tracing_agent_and_use_tracing_tracingcontroller_instead.patch index 85160f50173f..93091bcb2202 100644 --- a/patches/node/fix_expose_tracing_agent_and_use_tracing_tracingcontroller_instead.patch +++ b/patches/node/fix_expose_tracing_agent_and_use_tracing_tracingcontroller_instead.patch @@ -7,10 +7,10 @@ Subject: fix: expose tracing::Agent and use tracing::TracingController instead This API is used by Electron to create Node's tracing controller. diff --git a/src/api/environment.cc b/src/api/environment.cc -index 86498671b5df02e92b9c081cbc1cb99851348a14..e3b4cd710d045a98e1d127adcbc557f5f724d443 100644 +index 0de7ae88c2a715aa85a83217a2d9b2532e3be1f0..89236434d4816f619b30fe30bee1046a61c598ae 100644 --- a/src/api/environment.cc +++ b/src/api/environment.cc -@@ -502,6 +502,10 @@ MultiIsolatePlatform* GetMultiIsolatePlatform(IsolateData* env) { +@@ -516,6 +516,10 @@ MultiIsolatePlatform* GetMultiIsolatePlatform(IsolateData* env) { return env->platform(); } @@ -22,7 +22,7 @@ index 86498671b5df02e92b9c081cbc1cb99851348a14..e3b4cd710d045a98e1d127adcbc557f5 int thread_pool_size, node::tracing::TracingController* tracing_controller) { diff --git a/src/node.h b/src/node.h -index 58ff9010c78f317788d4fc47cc2143faca96a49c..9579b04472350fca5b5dbce354d373b50f873972 100644 +index 04edec35975c6b9db1d44e896d92a9f5bc606d51..8314edbc82971148310c5c99e5a4b18dffa14e51 100644 --- a/src/node.h +++ b/src/node.h @@ -129,6 +129,7 @@ namespace node { @@ -33,7 +33,7 @@ index 58ff9010c78f317788d4fc47cc2143faca96a49c..9579b04472350fca5b5dbce354d373b5 class TracingController; } -@@ -652,6 +653,8 @@ NODE_EXTERN void GetNodeReport(Environment* env, +@@ -671,6 +672,8 @@ NODE_EXTERN void GetNodeReport(Environment* env, NODE_EXTERN MultiIsolatePlatform* GetMultiIsolatePlatform(Environment* env); NODE_EXTERN MultiIsolatePlatform* GetMultiIsolatePlatform(IsolateData* env); diff --git a/patches/node/fix_handle_boringssl_and_openssl_incompatibilities.patch b/patches/node/fix_handle_boringssl_and_openssl_incompatibilities.patch index 9da2c2809461..49ac942b6303 100644 --- a/patches/node/fix_handle_boringssl_and_openssl_incompatibilities.patch +++ b/patches/node/fix_handle_boringssl_and_openssl_incompatibilities.patch @@ -31,10 +31,10 @@ index 2685f5ea0bea998094453a5a29d23b1aaae55667..0ad4ba47b50a87bcf9e31a73c20a3a51 case EVP_CIPH_GCM_MODE: #ifndef OPENSSL_NO_OCB diff --git a/src/crypto/crypto_common.cc b/src/crypto/crypto_common.cc -index a1d0dfc16ce23503b0985ec6e185fb54758c8893..85daa8c8c12c28571f0ee739868549335cb1f730 100644 +index 41e607e9298314bd7dd9e61643650f3ec75caea8..bd3228a67e1bda671488b347bd53ca805f09be87 100644 --- a/src/crypto/crypto_common.cc +++ b/src/crypto/crypto_common.cc -@@ -159,7 +159,7 @@ const char* GetClientHelloALPN(const SSLPointer& ssl) { +@@ -158,7 +158,7 @@ const char* GetClientHelloALPN(const SSLPointer& ssl) { const unsigned char* buf; size_t len; size_t rem; @@ -43,7 +43,7 @@ index a1d0dfc16ce23503b0985ec6e185fb54758c8893..85daa8c8c12c28571f0ee73986854933 if (!SSL_client_hello_get0_ext( ssl.get(), TLSEXT_TYPE_application_layer_protocol_negotiation, -@@ -172,13 +172,15 @@ const char* GetClientHelloALPN(const SSLPointer& ssl) { +@@ -171,13 +171,15 @@ const char* GetClientHelloALPN(const SSLPointer& ssl) { len = (buf[0] << 8) | buf[1]; if (len + 2 != rem) return nullptr; return reinterpret_cast(buf + 3); @@ -60,7 +60,7 @@ index a1d0dfc16ce23503b0985ec6e185fb54758c8893..85daa8c8c12c28571f0ee73986854933 if (!SSL_client_hello_get0_ext( ssl.get(), TLSEXT_TYPE_server_name, -@@ -200,15 +202,20 @@ const char* GetClientHelloServerName(const SSLPointer& ssl) { +@@ -199,15 +201,20 @@ const char* GetClientHelloServerName(const SSLPointer& ssl) { if (len + 2 > rem) return nullptr; return reinterpret_cast(buf + 5); @@ -84,7 +84,7 @@ index a1d0dfc16ce23503b0985ec6e185fb54758c8893..85daa8c8c12c28571f0ee73986854933 const char* X509ErrorCode(long err) { // NOLINT(runtime/int) const char* code = "UNSPECIFIED"; -@@ -1039,14 +1046,14 @@ MaybeLocal GetClientHelloCiphers( +@@ -1048,14 +1055,14 @@ MaybeLocal GetClientHelloCiphers( Environment* env, const SSLPointer& ssl) { EscapableHandleScope scope(env->isolate()); @@ -103,6 +103,23 @@ index a1d0dfc16ce23503b0985ec6e185fb54758c8893..85daa8c8c12c28571f0ee73986854933 Local obj = Object::New(env->isolate()); if (!Set(env->context(), obj, +diff --git a/src/crypto/crypto_context.cc b/src/crypto/crypto_context.cc +index b9f323035ff543ecb6f7bd577512729f0d60a156..0262dee543359c85c2c293ee22a8697b05f75feb 100644 +--- a/src/crypto/crypto_context.cc ++++ b/src/crypto/crypto_context.cc +@@ -857,10 +857,12 @@ void SecureContext::SetDHParam(const FunctionCallbackInfo& args) { + // If the user specified "auto" for dhparams, the JavaScript layer will pass + // true to this function instead of the original string. Any other string + // value will be interpreted as custom DH parameters below. ++#ifndef OPENSSL_IS_BORINGSSL + if (args[0]->IsTrue()) { + CHECK(SSL_CTX_set_dh_auto(sc->ctx_.get(), true)); + return; + } ++#endif + + DHPointer dh; + { diff --git a/src/crypto/crypto_dh.cc b/src/crypto/crypto_dh.cc index dd69323b80076d7333b80453c9cc9ef5b680ce27..6431b768c83fa27b2287588e936f93ae00169ad5 100644 --- a/src/crypto/crypto_dh.cc @@ -248,10 +265,10 @@ index 47a42246eddfc795b735f5efd08edf2832bbf6c1..7e6afaa1d3a4612fd567924b40438a31 if (target diff --git a/src/crypto/crypto_util.cc b/src/crypto/crypto_util.cc -index 8ead5fcbb55afbdf657603e85fddf28ac4874e04..e12ccf8162ee799beb3d4f0832054b5c4d397631 100644 +index 247067a9908717ba1323bd610eeeedf3aba008a4..0fe7358d3f419f6e6f00eb4cc8422e9c5cb6cb9a 100644 --- a/src/crypto/crypto_util.cc +++ b/src/crypto/crypto_util.cc -@@ -507,24 +507,15 @@ Maybe Decorate(Environment* env, Local obj, +@@ -508,24 +508,15 @@ Maybe Decorate(Environment* env, Local obj, V(BIO) \ V(PKCS7) \ V(X509V3) \ @@ -277,7 +294,7 @@ index 8ead5fcbb55afbdf657603e85fddf28ac4874e04..e12ccf8162ee799beb3d4f0832054b5c V(USER) \ #define V(name) case ERR_LIB_##name: lib = #name "_"; break; -@@ -698,7 +689,7 @@ void SecureBuffer(const FunctionCallbackInfo& args) { +@@ -699,7 +690,7 @@ void SecureBuffer(const FunctionCallbackInfo& args) { CHECK(args[0]->IsUint32()); Environment* env = Environment::GetCurrent(args); uint32_t len = args[0].As()->Value(); @@ -286,7 +303,7 @@ index 8ead5fcbb55afbdf657603e85fddf28ac4874e04..e12ccf8162ee799beb3d4f0832054b5c if (data == nullptr) { // There's no memory available for the allocation. // Return nothing. -@@ -709,7 +700,7 @@ void SecureBuffer(const FunctionCallbackInfo& args) { +@@ -710,7 +701,7 @@ void SecureBuffer(const FunctionCallbackInfo& args) { data, len, [](void* data, size_t len, void* deleter_data) { @@ -295,7 +312,7 @@ index 8ead5fcbb55afbdf657603e85fddf28ac4874e04..e12ccf8162ee799beb3d4f0832054b5c }, data); Local buffer = ArrayBuffer::New(env->isolate(), store); -@@ -717,10 +708,12 @@ void SecureBuffer(const FunctionCallbackInfo& args) { +@@ -718,10 +709,12 @@ void SecureBuffer(const FunctionCallbackInfo& args) { } void SecureHeapUsed(const FunctionCallbackInfo& args) { @@ -309,10 +326,10 @@ index 8ead5fcbb55afbdf657603e85fddf28ac4874e04..e12ccf8162ee799beb3d4f0832054b5c } // namespace diff --git a/src/node_metadata.cc b/src/node_metadata.cc -index ed28871c385532b13e102200ba549bb7d7e901e6..c69d3f1867cd1b86194b109351643d9520c661e7 100644 +index 6fe09f843e26b7f29faadf5035d368ed8b7eba38..326a9ee8a6d24d0c78537bfe5d9da394a439da90 100644 --- a/src/node_metadata.cc +++ b/src/node_metadata.cc -@@ -13,7 +13,7 @@ +@@ -14,7 +14,7 @@ #include "v8.h" #include "zlib.h" @@ -322,7 +339,7 @@ index ed28871c385532b13e102200ba549bb7d7e901e6..c69d3f1867cd1b86194b109351643d95 #if NODE_OPENSSL_HAS_QUIC #include diff --git a/src/node_metadata.h b/src/node_metadata.h -index 2a924141d6edbaade371dd29d553eb1107ff5f75..be37169bb1d5e70e11601ccf00db0552ee3511ed 100644 +index 1831bfd0baaac70277fc274a72235bf6a04697cb..1c0a3fcdeb44dc947bb8c38459533779575379da 100644 --- a/src/node_metadata.h +++ b/src/node_metadata.h @@ -6,7 +6,7 @@ @@ -335,13 +352,13 @@ index 2a924141d6edbaade371dd29d553eb1107ff5f75..be37169bb1d5e70e11601ccf00db0552 #if NODE_OPENSSL_HAS_QUIC #include diff --git a/src/node_options.cc b/src/node_options.cc -index 6eabf78f1b67c8f31a9faac16386e00f2f9427f3..bc3c58b0ce8666f978de39ef57832b077bb181a3 100644 +index 6e156fa1ba448f8d0c709eb7ba7112e92909a8fc..8bbee83ddb32a31ada18d7a6e8be7cdf33321b69 100644 --- a/src/node_options.cc +++ b/src/node_options.cc -@@ -5,7 +5,7 @@ - #include "node_binding.h" +@@ -6,7 +6,7 @@ #include "node_external_reference.h" #include "node_internals.h" + #include "node_sea.h" -#if HAVE_OPENSSL +#if HAVE_OPENSSL && !defined(OPENSSL_IS_BORINGSSL) #include "openssl/opensslv.h" diff --git a/patches/node/fix_libc_buffer_overflow_in_string_view_ctor.patch b/patches/node/fix_libc_buffer_overflow_in_string_view_ctor.patch new file mode 100644 index 000000000000..fe8cc72968da --- /dev/null +++ b/patches/node/fix_libc_buffer_overflow_in_string_view_ctor.patch @@ -0,0 +1,40 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Shelley Vohr +Date: Tue, 18 Apr 2023 11:24:59 +0200 +Subject: fix: libc++ buffer overflow in string_view ctor + +Refs https://github.com/nodejs/node/pull/46410 +Refs https://github.com/llvm/llvm-project/issues/61100. + +Fixes a buffer overflow crash in std::string view constructor. This +happens as a result of a limitation of libc++'s implementation of the +string_view constructor. If string_view receives a pointer to a string start point, +and then a length as a size_t, the spec says that a size_t that exceeds the length +of the null terminated string found at pointer only be read up until the null terminator. + +However, Chromium's implementation however does a hard check that this length is less than +or equal to static_cast(std::numeric_limits::max()): +https://source.chromium.org/chromium/chromium/src/+/main:buildtools/third_party/libc++/trunk/include/string_view;drc=1718a75513d114e6b9aa4474e5c55d8dabee92fb;l=309 + +This doesn't break in Node.js right now because that hard assert is missing, but will +break in the next version of Xcode that's shipped and this Node.js too. + +This should be upstreamed to ada. + +diff --git a/deps/ada/ada.cpp b/deps/ada/ada.cpp +index 8b2cdd38ad0bb1e5757cdf5724c5a5917fc8e577..7d2f75fe559c1878e129aa681c86d6780d2e8233 100644 +--- a/deps/ada/ada.cpp ++++ b/deps/ada/ada.cpp +@@ -825,8 +825,10 @@ namespace ada::helpers { + + // Let path be url’s path. + // If url’s scheme is "file", path’s size is 1, and path[0] is a normalized Windows drive letter, then return. +- if (type == ada::scheme::type::FILE && first_delimiter == std::string_view::npos) { +- if (checkers::is_normalized_windows_drive_letter(std::string_view(path.data() + 1, first_delimiter - 1))) { ++ if (!path.empty() && type == ada::scheme::type::FILE && ++ first_delimiter == std::string_view::npos) { ++ if (checkers::is_normalized_windows_drive_letter( ++ std::string_view(path.data() + 1, path.length() - 1))) { + return; + } + } diff --git a/patches/node/fix_preventing_potential_oob_in_ada_no_scheme_parsing.patch b/patches/node/fix_preventing_potential_oob_in_ada_no_scheme_parsing.patch new file mode 100644 index 000000000000..44596f96ce2a --- /dev/null +++ b/patches/node/fix_preventing_potential_oob_in_ada_no_scheme_parsing.patch @@ -0,0 +1,21 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Shelley Vohr +Date: Tue, 18 Apr 2023 15:08:05 +0200 +Subject: fix: preventing potential oob in ada NO_SCHEME parsing + +https://github.com/ada-url/ada/pull/286 + +diff --git a/deps/ada/ada.cpp b/deps/ada/ada.cpp +index 7d2f75fe559c1878e129aa681c86d6780d2e8233..7bf541834d22511eefcc58517cc75117f53eb475 100644 +--- a/deps/ada/ada.cpp ++++ b/deps/ada/ada.cpp +@@ -2243,7 +2243,8 @@ namespace ada::parser { + ada_log("NO_SCHEME ", helpers::substring(url_data, input_position)); + // If base is null, or base has an opaque path and c is not U+0023 (#), validation error, return failure. + // SCHEME state updates the state to NO_SCHEME and validates url_data is not empty. +- if (base_url == nullptr || (base_url->has_opaque_path && url_data[input_position] != '#')) { ++ if (base_url == nullptr || ++ (base_url->has_opaque_path && !fragment.has_value())) { + ada_log("NO_SCHEME validation error"); + url.is_valid = false; + return url; diff --git a/patches/node/fixup_for_error_declaration_shadows_a_local_variable.patch b/patches/node/fixup_for_error_declaration_shadows_a_local_variable.patch deleted file mode 100644 index 0191101c40b5..000000000000 --- a/patches/node/fixup_for_error_declaration_shadows_a_local_variable.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: John Kleinschmidt -Date: Thu, 1 Sep 2022 15:31:47 -0400 -Subject: fixup for error: declaration shadows a local variable - [-Werror,-Wshadow] - -This was triggered by 3860569: Enable -Wshadow on Linux. - -https://chromium-review.googlesource.com/c/chromium/src/+/3860569 - -diff --git a/src/node_options-inl.h b/src/node_options-inl.h -old mode 100644 -new mode 100755 -index 01592b32b842ac96ccd3d06d7f8ddfa4222ca72e..c217a3ef1c0ff1ea7d108d1aa17e75e5433faa0d ---- a/src/node_options-inl.h -+++ b/src/node_options-inl.h -@@ -387,12 +387,12 @@ void OptionsParser::Parse( - implied_name.insert(2, "no-"); - } - auto implications = implications_.equal_range(implied_name); -- for (auto it = implications.first; it != implications.second; ++it) { -- if (it->second.type == kV8Option) { -- v8_args->push_back(it->second.name); -+ for (auto it2 = implications.first; it2 != implications.second; ++it2) { -+ if (it2->second.type == kV8Option) { -+ v8_args->push_back(it2->second.name); - } else { -- *it->second.target_field->template Lookup(options) = -- it->second.target_value; -+ *it2->second.target_field->template Lookup(options) = -+ it2->second.target_value; - } - } - } diff --git a/patches/node/lib_fix_broadcastchannel_initialization_location.patch b/patches/node/lib_fix_broadcastchannel_initialization_location.patch deleted file mode 100644 index 79bfe759818f..000000000000 --- a/patches/node/lib_fix_broadcastchannel_initialization_location.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Shelley Vohr -Date: Mon, 27 Feb 2023 12:56:15 +0100 -Subject: lib: fix BroadcastChannel initialization location - -Refs https://github.com/nodejs/node/pull/40532. - -Fixes a bug in the above, wherein BroadcastChannel should have been -initialized in bootstrap/browser instead of bootstrap/node. That -inadvertently made it such that there was incorrect handling of the -DOM vs Node.js implementations of BroadcastChannel. - -Upstreamed in https://github.com/nodejs/node/pull/46864. - -diff --git a/lib/internal/bootstrap/browser.js b/lib/internal/bootstrap/browser.js -index d0c01ca2a512be549b0fea8a829c05eabbec799a..210a1bb7e929021725b04786bc11d9b3ce09ad04 100644 ---- a/lib/internal/bootstrap/browser.js -+++ b/lib/internal/bootstrap/browser.js -@@ -12,6 +12,10 @@ const { - } = require('internal/util'); - const config = internalBinding('config'); - -+// Non-standard extensions: -+const { BroadcastChannel } = require('internal/worker/io'); -+exposeInterface(globalThis, 'BroadcastChannel', BroadcastChannel); -+ - // https://console.spec.whatwg.org/#console-namespace - exposeNamespace(globalThis, 'console', - createGlobalConsole()); -diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js -index 8e714227c4fec6f3aa1d09382d70467d69ca8460..dae0ed3947fd6442a0a7e9028c072047874d5bce 100644 ---- a/lib/internal/bootstrap/node.js -+++ b/lib/internal/bootstrap/node.js -@@ -238,10 +238,6 @@ const { - queueMicrotask - } = require('internal/process/task_queues'); - --// Non-standard extensions: --const { BroadcastChannel } = require('internal/worker/io'); --exposeInterface(globalThis, 'BroadcastChannel', BroadcastChannel); -- - defineOperation(globalThis, 'queueMicrotask', queueMicrotask); - - const timers = require('timers'); diff --git a/patches/node/pass_all_globals_through_require.patch b/patches/node/pass_all_globals_through_require.patch index 3fb41fdacc47..b6b6b8914720 100644 --- a/patches/node/pass_all_globals_through_require.patch +++ b/patches/node/pass_all_globals_through_require.patch @@ -6,7 +6,7 @@ Subject: Pass all globals through "require" (cherry picked from commit 7d015419cb7a0ecfe6728431a4ed2056cd411d62) diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js -index 42e5cc50105560174b3106898d20ef11ea37be85..6b9aef981cfa934e1321916828d4f921008134d6 100644 +index 31649227ed8eb36f58ec0b88d498b9e45009f76b..61605a052f976dc7fad224c3c81c2187f3862cdb 100644 --- a/lib/internal/modules/cjs/loader.js +++ b/lib/internal/modules/cjs/loader.js @@ -142,6 +142,13 @@ const { @@ -21,7 +21,7 @@ index 42e5cc50105560174b3106898d20ef11ea37be85..6b9aef981cfa934e1321916828d4f921 +const localBuffer = Buffer; + const { - isProxy + isProxy, } = require('internal/util/types'); @@ -1249,10 +1256,12 @@ Module.prototype._compile = function(content, filename) { if (requireDepth === 0) statCache = new SafeMap(); diff --git a/patches/node/refactor_allow_embedder_overriding_of_internal_fs_calls.patch b/patches/node/refactor_allow_embedder_overriding_of_internal_fs_calls.patch index ba981218f24f..29242e591f21 100644 --- a/patches/node/refactor_allow_embedder_overriding_of_internal_fs_calls.patch +++ b/patches/node/refactor_allow_embedder_overriding_of_internal_fs_calls.patch @@ -7,7 +7,7 @@ We use this to allow node's 'fs' module to read from ASAR files as if they were a real filesystem. diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js -index 1156bcb3150fb53fbb085265e20adca0bec6b24b..8e714227c4fec6f3aa1d09382d70467d69ca8460 100644 +index 07c6d5e9351a96aeca1179c20287dc3fb7ec1eab..13ea68c96fd415f976aab0f291a1b7c688db1c58 100644 --- a/lib/internal/bootstrap/node.js +++ b/lib/internal/bootstrap/node.js @@ -101,6 +101,10 @@ process.domain = null; @@ -22,7 +22,7 @@ index 1156bcb3150fb53fbb085265e20adca0bec6b24b..8e714227c4fec6f3aa1d09382d70467d // release cycle, remove the Proxy and setter and update the // getter to either return a read-only object or always return diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js -index 6b9aef981cfa934e1321916828d4f921008134d6..c19cd5e5d8a818c52406c78b95d96bae1b1f41bd 100644 +index 61605a052f976dc7fad224c3c81c2187f3862cdb..f2e8dc028b8b60108f1aa2301d65001b5a3774c7 100644 --- a/lib/internal/modules/cjs/loader.js +++ b/lib/internal/modules/cjs/loader.js @@ -94,7 +94,7 @@ const fs = require('fs'); @@ -44,7 +44,7 @@ index 6b9aef981cfa934e1321916828d4f921008134d6..c19cd5e5d8a818c52406c78b95d96bae // Only set cache when `internalModuleStat(filename)` succeeds. statCache.set(filename, result); diff --git a/lib/internal/modules/package_json_reader.js b/lib/internal/modules/package_json_reader.js -index 09eb12bd1533bfed44d9cb62c068e2c880df8ba2..11a6e4b2edc0930049d7acecf2a6e94e51abeb1c 100644 +index bb175d0df54c043075103dd394fd1f52c911e8dd..09ced1246cb6a8c2df764893c077177d23cb0414 100644 --- a/lib/internal/modules/package_json_reader.js +++ b/lib/internal/modules/package_json_reader.js @@ -1,7 +1,7 @@ @@ -62,6 +62,6 @@ index 09eb12bd1533bfed44d9cb62c068e2c880df8ba2..11a6e4b2edc0930049d7acecf2a6e94e - const { 0: string, 1: containsKeys } = internalModuleReadJSON( + const { 0: string, 1: containsKeys } = internalFsBinding.internalModuleReadJSON( - toNamespacedPath(jsonPath) + toNamespacedPath(jsonPath), ); const result = { string, containsKeys }; diff --git a/patches/node/refactor_alter_child_process_fork_to_use_execute_script_with.patch b/patches/node/refactor_alter_child_process_fork_to_use_execute_script_with.patch index 821271b0a346..5cd31707dfe6 100644 --- a/patches/node/refactor_alter_child_process_fork_to_use_execute_script_with.patch +++ b/patches/node/refactor_alter_child_process_fork_to_use_execute_script_with.patch @@ -7,7 +7,7 @@ Subject: refactor: alter child_process.fork to use execute script with When forking a child script, we setup a special environment to make the Electron binary run like the upstream node. On Mac, we use the helper app as node binary. diff --git a/lib/child_process.js b/lib/child_process.js -index 55e6b781cd00699921bf138b757fc3555942646b..1bc5f92181a48e1ee37e59220ad11a755b20c9f4 100644 +index 5d3e2d63a744c20fd325e07107c50da5757c0a99..07ad7906a7be156926d0c770c3d766c1a411203b 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -137,7 +137,18 @@ function fork(modulePath, args = [], options) { diff --git a/patches/node/repl_fix_crash_when_sharedarraybuffer_disabled.patch b/patches/node/repl_fix_crash_when_sharedarraybuffer_disabled.patch deleted file mode 100644 index 39453395db5c..000000000000 --- a/patches/node/repl_fix_crash_when_sharedarraybuffer_disabled.patch +++ /dev/null @@ -1,62 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Shelley Vohr -Date: Mon, 9 Aug 2021 18:42:15 +0200 -Subject: repl: fix crash when SharedArrayBuffer disabled - -It's possible for SharedArrayBuffers to be disabled with ---no-harmony-sharedarraybuffer so we first need to check that this -isn't the case before attempting to use them in the repl or a crash occurs. - -Upstreamed at https://github.com/nodejs/node/pull/39718. - -diff --git a/benchmark/worker/atomics-wait.js b/benchmark/worker/atomics-wait.js -index 7270f9f01c98ece3dc38bf56d270d7e08d39f66e..44db021ad37af4ae9c4526a405cea8bc3c1909a5 100644 ---- a/benchmark/worker/atomics-wait.js -+++ b/benchmark/worker/atomics-wait.js -@@ -7,6 +7,10 @@ const bench = common.createBenchmark(main, { - }); - - function main({ n }) { -+ if (typeof SharedArrayBuffer === 'undefined') { -+ throw new Error('SharedArrayBuffers must be enabled to run this benchmark'); -+ } -+ - const i32arr = new Int32Array(new SharedArrayBuffer(4)); - bench.start(); - for (let i = 0; i < n; i++) -diff --git a/lib/internal/main/worker_thread.js b/lib/internal/main/worker_thread.js -index fe2e132af1166a05c3e94cdae362dd46f62bf65b..caa9214fa30a715a5eea00e7fc3b091e40c07131 100644 ---- a/lib/internal/main/worker_thread.js -+++ b/lib/internal/main/worker_thread.js -@@ -10,7 +10,7 @@ const { - ObjectDefineProperty, - PromisePrototypeThen, - RegExpPrototypeExec, -- globalThis: { Atomics }, -+ globalThis: { Atomics, SharedArrayBuffer }, - } = primordials; - - const { -@@ -113,6 +113,8 @@ port.on('message', (message) => { - - process.cwd = function() { - const currentCounter = Atomics.load(cwdCounter, 0); -+ // SharedArrayBuffers can be disabled with --no-harmony-sharedarraybuffer. -+ if (typeof SharedArrayBuffer === 'undefined') return originalCwd(); - if (currentCounter === lastCounter) - return cachedCwd; - lastCounter = currentCounter; -diff --git a/lib/internal/worker.js b/lib/internal/worker.js -index 8e396195209b83dff572792a78ee75d12d1f6610..4bb09b6ab5c31206a622814cbcd793c434b885d4 100644 ---- a/lib/internal/worker.js -+++ b/lib/internal/worker.js -@@ -91,7 +91,8 @@ let cwdCounter; - - const environmentData = new SafeMap(); - --if (isMainThread) { -+// SharedArrayBuffers can be disabled with --no-harmony-sharedarraybuffer. -+if (isMainThread && typeof SharedArrayBuffer !== 'undefined') { - cwdCounter = new Uint32Array(new SharedArrayBuffer(4)); - const originalChdir = process.chdir; - process.chdir = function(path) { diff --git a/patches/node/src_allow_optional_isolation_termination_in_node.patch b/patches/node/src_allow_optional_isolation_termination_in_node.patch deleted file mode 100644 index 90c66561d040..000000000000 --- a/patches/node/src_allow_optional_isolation_termination_in_node.patch +++ /dev/null @@ -1,75 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Shelley Vohr -Date: Tue, 7 Feb 2023 10:53:11 +0100 -Subject: src: allow optional isolation termination in node - -This patch allows for node::Stop() to conditionally call -V8:Isolate::TerminateExecution(). - -We do not want to invoke a termination exception at exit when -we're running with only_terminate_in_safe_scope set to false. Heap and -coverage profilers run after environment exit and if there is a pending -exception at this stage then they will fail to generate the appropriate -profiles. Node.js does not call node::Stop(), which previously always -called isolate->TerminateExecution(), and therefore does not have this -issue when also running with only_terminate_in_safe_scope set to false. - -diff --git a/src/env.cc b/src/env.cc -index 837a879864c46d6f500684444ec38583c05f8be2..69a8b9ea405a400254041734b037c00aff4758f7 100644 ---- a/src/env.cc -+++ b/src/env.cc -@@ -902,10 +902,11 @@ void Environment::InitializeLibuv() { - StartProfilerIdleNotifier(); - } - --void Environment::ExitEnv() { -+void Environment::ExitEnv(bool terminate) { - // Should not access non-thread-safe methods here. - set_stopping(true); -- isolate_->TerminateExecution(); -+ if (terminate) -+ isolate_->TerminateExecution(); - SetImmediateThreadsafe([](Environment* env) { - env->set_can_call_into_js(false); - uv_stop(env->event_loop()); -diff --git a/src/env.h b/src/env.h -index 562610e6827d8302f146b81d599dd366ba25cd74..c358c139aafcd7c958915b036f8d176909341556 100644 ---- a/src/env.h -+++ b/src/env.h -@@ -628,7 +628,7 @@ class Environment : public MemoryRetainer { - void RegisterHandleCleanups(); - void CleanupHandles(); - void Exit(int code); -- void ExitEnv(); -+ void ExitEnv(bool terminate); - - // Register clean-up cb to be called on environment destruction. - inline void RegisterHandleCleanup(uv_handle_t* handle, -diff --git a/src/node.cc b/src/node.cc -index 1067dee74c8877d9a3a0da6527c4c37faf9bd15f..b550fd4aa8488c6d721db3dee94cc4ce1346c708 100644 ---- a/src/node.cc -+++ b/src/node.cc -@@ -1229,8 +1229,8 @@ int Start(int argc, char** argv) { - return LoadSnapshotDataAndRun(&snapshot_data, result.get()); - } - --int Stop(Environment* env) { -- env->ExitEnv(); -+int Stop(Environment* env, bool terminate) { -+ env->ExitEnv(terminate); - return 0; - } - -diff --git a/src/node.h b/src/node.h -index 47ac8c24ef5e26822f694b583767e850fc5f7d96..f1fb363becf1f1b3b3ef0b2782c6561d29aa7cbd 100644 ---- a/src/node.h -+++ b/src/node.h -@@ -316,7 +316,7 @@ NODE_EXTERN int Start(int argc, char* argv[]); - - // Tear down Node.js while it is running (there are active handles - // in the loop and / or actively executing JavaScript code). --NODE_EXTERN int Stop(Environment* env); -+NODE_EXTERN int Stop(Environment* env, bool terminate = true); - - // This runs a subset of the initialization performed by - // InitializeOncePerProcess(), which supersedes this function. diff --git a/patches/node/support_v8_sandboxed_pointers.patch b/patches/node/support_v8_sandboxed_pointers.patch index 9c28068ece1e..52ee2398834c 100644 --- a/patches/node/support_v8_sandboxed_pointers.patch +++ b/patches/node/support_v8_sandboxed_pointers.patch @@ -7,7 +7,7 @@ This refactors several allocators to allocate within the V8 memory cage, allowing them to be compatible with the V8_SANDBOXED_POINTERS feature. diff --git a/src/api/environment.cc b/src/api/environment.cc -index e3b4cd710d045a98e1d127adcbc557f5f724d443..a994221445471b92d12ed9cb3bef9ffb70670ab6 100644 +index 89236434d4816f619b30fe30bee1046a61c598ae..53db99ed5d2d9811eef2db26021c982890cc9cbe 100644 --- a/src/api/environment.cc +++ b/src/api/environment.cc @@ -86,6 +86,14 @@ MaybeLocal PrepareStackTraceCallback(Local context, @@ -26,10 +26,10 @@ index e3b4cd710d045a98e1d127adcbc557f5f724d443..a994221445471b92d12ed9cb3bef9ffb void* ret; if (zero_fill_field_ || per_process::cli_options->zero_fill_all_buffers) diff --git a/src/crypto/crypto_util.cc b/src/crypto/crypto_util.cc -index e12ccf8162ee799beb3d4f0832054b5c4d397631..aa65c99f2ac29c9ce9d15b968f0ce7b8d5750563 100644 +index 0fe7358d3f419f6e6f00eb4cc8422e9c5cb6cb9a..1a8337412f2fe1f10df280fbf8bdefb8982b9f74 100644 --- a/src/crypto/crypto_util.cc +++ b/src/crypto/crypto_util.cc -@@ -338,10 +338,35 @@ ByteSource& ByteSource::operator=(ByteSource&& other) noexcept { +@@ -339,10 +339,35 @@ ByteSource& ByteSource::operator=(ByteSource&& other) noexcept { return *this; } @@ -66,7 +66,7 @@ index e12ccf8162ee799beb3d4f0832054b5c4d397631..aa65c99f2ac29c9ce9d15b968f0ce7b8 std::unique_ptr ptr = ArrayBuffer::NewBackingStore( allocated_data_, size(), -@@ -353,10 +378,11 @@ std::unique_ptr ByteSource::ReleaseToBackingStore() { +@@ -354,10 +379,11 @@ std::unique_ptr ByteSource::ReleaseToBackingStore() { data_ = nullptr; size_ = 0; return ptr; @@ -79,7 +79,7 @@ index e12ccf8162ee799beb3d4f0832054b5c4d397631..aa65c99f2ac29c9ce9d15b968f0ce7b8 return ArrayBuffer::New(env->isolate(), std::move(store)); } -@@ -685,6 +711,16 @@ namespace { +@@ -686,6 +712,16 @@ namespace { // in which case this has the same semantics as // using OPENSSL_malloc. However, if the secure heap is // initialized, SecureBuffer will automatically use it. @@ -96,7 +96,7 @@ index e12ccf8162ee799beb3d4f0832054b5c4d397631..aa65c99f2ac29c9ce9d15b968f0ce7b8 void SecureBuffer(const FunctionCallbackInfo& args) { CHECK(args[0]->IsUint32()); Environment* env = Environment::GetCurrent(args); -@@ -706,6 +742,7 @@ void SecureBuffer(const FunctionCallbackInfo& args) { +@@ -707,6 +743,7 @@ void SecureBuffer(const FunctionCallbackInfo& args) { Local buffer = ArrayBuffer::New(env->isolate(), store); args.GetReturnValue().Set(Uint8Array::New(buffer, 0, len)); } @@ -131,10 +131,10 @@ index bb810632ee6617759d9cbd24c84a5d1a3a6081aa..3faf9840eddf2db993baef0866bc8854 return ret; diff --git a/src/node_internals.h b/src/node_internals.h -index ece9a4cfd45bf885169fdd278e09c467c6b4bbab..0c0dac67c0834ab7feba4260796292456a24c08d 100644 +index 427cfab4eebcab0aed33e42915f4a0e5a9db7cdf..d174b2720b0b2561ebe30437df609e0366388527 100644 --- a/src/node_internals.h +++ b/src/node_internals.h -@@ -99,7 +99,9 @@ v8::Maybe InitializePrimordials(v8::Local context); +@@ -102,7 +102,9 @@ v8::Maybe InitializePrimordials(v8::Local context); class NodeArrayBufferAllocator : public ArrayBufferAllocator { public: @@ -145,7 +145,7 @@ index ece9a4cfd45bf885169fdd278e09c467c6b4bbab..0c0dac67c0834ab7feba426079629245 void* Allocate(size_t size) override; // Defined in src/node.cc void* AllocateUninitialized(size_t size) override; -@@ -118,7 +120,7 @@ class NodeArrayBufferAllocator : public ArrayBufferAllocator { +@@ -121,7 +123,7 @@ class NodeArrayBufferAllocator : public ArrayBufferAllocator { } private: diff --git a/patches/node/v8_api_advance_api_deprecation.patch b/patches/node/v8_api_advance_api_deprecation.patch index d79dd5cf6908..1b1ada3a92c4 100644 --- a/patches/node/v8_api_advance_api_deprecation.patch +++ b/patches/node/v8_api_advance_api_deprecation.patch @@ -8,7 +8,7 @@ Refs https://chromium-review.googlesource.com/c/v8/v8/+/3702449 This can be removed when Electron upgrades to Node.js v20. diff --git a/src/inspector_agent.cc b/src/inspector_agent.cc -index 1abf6801e0544b14dd26f0b96536bd78c5b01679..93e339602800a21726c9414bf2ebe9a2e5517a3b 100644 +index e5307b529c88d0e4db7fd7c6bd1b032d219b8c31..f6923be7a9ccdac2396cb625b227094f2686e54b 100644 --- a/src/inspector_agent.cc +++ b/src/inspector_agent.cc @@ -219,7 +219,8 @@ class ChannelImpl final : public v8_inspector::V8Inspector::Channel, diff --git a/script/node-disabled-tests.json b/script/node-disabled-tests.json index a5d98ecd77e6..d57b37a9c46d 100644 --- a/script/node-disabled-tests.json +++ b/script/node-disabled-tests.json @@ -41,6 +41,7 @@ "parallel/test-process-versions", "parallel/test-repl", "parallel/test-repl-underscore", + "parallel/test-single-executable-application", "parallel/test-snapshot-api", "parallel/test-snapshot-basic", "parallel/test-snapshot-console", @@ -58,6 +59,7 @@ "parallel/test-snapshot-weak-reference", "parallel/test-snapshot-typescript", "parallel/test-stdout-close-catch", + "parallel/test-strace-openat-openssl", "parallel/test-tls-cert-chains-concat", "parallel/test-tls-cert-chains-in-ca", "parallel/test-tls-cli-max-version-1.2", diff --git a/shell/app/node_main.cc b/shell/app/node_main.cc index d7b785b02eff..2369bd5a859c 100644 --- a/shell/app/node_main.cc +++ b/shell/app/node_main.cc @@ -266,7 +266,7 @@ int NodeMain(int argc, char* argv[]) { node::ResetStdio(); - node::Stop(env, false); + node::Stop(env, node::StopFlags::kDoNotTerminateIsolate); node::FreeEnvironment(env); node::FreeIsolateData(isolate_data); diff --git a/shell/browser/electron_browser_main_parts.cc b/shell/browser/electron_browser_main_parts.cc index a1343d2058ed..b9db118c2eee 100644 --- a/shell/browser/electron_browser_main_parts.cc +++ b/shell/browser/electron_browser_main_parts.cc @@ -625,7 +625,7 @@ void ElectronBrowserMainParts::PostMainMessageLoopRun() { // invoke Node/V8 APIs inside them. node_env_->env()->set_trace_sync_io(false); js_env_->DestroyMicrotasksRunner(); - node::Stop(node_env_->env(), false); + node::Stop(node_env_->env(), node::StopFlags::kDoNotTerminateIsolate); node_env_.reset(); auto default_context_key = ElectronBrowserContext::PartitionKey("", false); diff --git a/shell/common/node_bindings.cc b/shell/common/node_bindings.cc index ca65a4fd6de0..83596790b737 100644 --- a/shell/common/node_bindings.cc +++ b/shell/common/node_bindings.cc @@ -599,6 +599,8 @@ node::Environment* NodeBindings::CreateEnvironment( // Use a custom callback here to allow us to leverage Blink's logic in the // renderer process. is.allow_wasm_code_generation_callback = AllowWasmCodeGenerationCallback; + is.flags |= node::IsolateSettingsFlags:: + ALLOW_MODIFY_CODE_GENERATION_FROM_STRINGS_CALLBACK; is.modify_code_generation_from_strings_callback = ModifyCodeGenerationFromStrings; diff --git a/shell/services/node/node_service.cc b/shell/services/node/node_service.cc index 58a1a9a2e027..6c84c5d219c1 100644 --- a/shell/services/node/node_service.cc +++ b/shell/services/node/node_service.cc @@ -33,7 +33,7 @@ NodeService::~NodeService() { if (!node_env_stopped_) { node_env_->env()->set_trace_sync_io(false); js_env_->DestroyMicrotasksRunner(); - node::Stop(node_env_->env(), false); + node::Stop(node_env_->env(), node::StopFlags::kDoNotTerminateIsolate); } } @@ -63,15 +63,15 @@ void NodeService::Initialize(node::mojom::NodeServiceParamsPtr params) { params->args, params->exec_args); node_env_ = std::make_unique(env); - node::SetProcessExitHandler(env, - [this](node::Environment* env, int exit_code) { - // Destroy node platform. - env->set_trace_sync_io(false); - js_env_->DestroyMicrotasksRunner(); - node::Stop(env, false); - node_env_stopped_ = true; - receiver_.ResetWithReason(exit_code, ""); - }); + node::SetProcessExitHandler( + env, [this](node::Environment* env, int exit_code) { + // Destroy node platform. + env->set_trace_sync_io(false); + js_env_->DestroyMicrotasksRunner(); + node::Stop(env, node::StopFlags::kDoNotTerminateIsolate); + node_env_stopped_ = true; + receiver_.ResetWithReason(exit_code, ""); + }); env->set_trace_sync_io(env->options()->trace_sync_io); diff --git a/spec/api-web-request-spec.ts b/spec/api-web-request-spec.ts index 359db9d9a8e0..136cd6c29333 100644 --- a/spec/api-web-request-spec.ts +++ b/spec/api-web-request-spec.ts @@ -22,7 +22,10 @@ describe('webRequest module', () => { res.setHeader('Location', 'http://' + req.rawHeaders[1]); res.end(); } else if (req.url === '/contentDisposition') { - res.setHeader('content-disposition', [' attachment; filename=aa%E4%B8%ADaa.txt']); + res.writeHead(200, [ + 'content-disposition', + Buffer.from('attachment; filename=aa中aa.txt').toString('binary') + ]); const content = req.url; res.end(content); } else { @@ -478,7 +481,8 @@ describe('webRequest module', () => { callback({}); }); const { data, headers } = await ajax(defaultURL + 'contentDisposition'); - expect(headers).to.to.have.property('content-disposition', 'attachment; filename=aa%E4%B8%ADaa.txt'); + const disposition = Buffer.from('attachment; filename=aa中aa.txt').toString('binary'); + expect(headers).to.to.have.property('content-disposition', disposition); expect(data).to.equal('/contentDisposition'); });