GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: add buildflag to force context-aware addons · jmdfm/node@3c17f16

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • doc/api
    • cli.md
    • errors.md
  • src
    • node_binding.cc
    • node_errors.h
    • node_options.cc
    • node_options.h
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/api/cli.md‎

Copy file name to clipboardExpand all lines: doc/api/cli.md
+8Lines changed: 8 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,13 @@ added: v6.0.0
411411

412412
Silence all process warnings (including deprecations).
413413

414+
### `--force-context-aware`
415+
<!-- YAML
416+
added: REPLACEME
417+
-->
418+
419+
Disable loading non-context-aware native addons.
420+
414421
### `--openssl-config=file`
415422
<!-- YAML
416423
added: v6.9.0
@@ -980,6 +987,7 @@ Node.js options that are allowed are:
980987
* `--experimental-report`
981988
* `--experimental-vm-modules`
982989
* `--experimental-wasm-modules`
990+
* `--force-context-aware`
983991
* `--force-fips`
984992
* `--frozen-intrinsics`
985993
* `--heapsnapshot-signal`
Collapse file

‎doc/api/errors.md‎

Copy file name to clipboardExpand all lines: doc/api/errors.md
+5Lines changed: 5 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1611,6 +1611,11 @@ OpenSSL crypto support.
16111611
An attempt was made to use features that require [ICU][], but Node.js was not
16121612
compiled with ICU support.
16131613

1614+
<a id="ERR_NON_CONTEXT_AWARE_DISABLED"></a>
1615+
### ERR_NON_CONTEXT_AWARE_DISABLED
1616+
1617+
A non-context-aware native addon was loaded in a process that disallows them.
1618+
16141619
<a id="ERR_OUT_OF_RANGE"></a>
16151620
### ERR_OUT_OF_RANGE
16161621

Collapse file

‎src/node_binding.cc‎

Copy file name to clipboardExpand all lines: src/node_binding.cc
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "node_binding.h"
2+
#include "node_errors.h"
23
#include <atomic>
34
#include "env-inl.h"
45
#include "node_native_module_env.h"
@@ -462,6 +463,13 @@ void DLOpen(const FunctionCallbackInfo<Value>& args) {
462463
}
463464

464465
if (mp != nullptr) {
466+
if (mp->nm_context_register_func == nullptr) {
467+
if (env->options()->force_context_aware) {
468+
dlib->Close();
469+
THROW_ERR_NON_CONTEXT_AWARE_DISABLED(env);
470+
return false;
471+
}
472+
}
465473
mp->nm_dso_handle = dlib->handle_;
466474
dlib->SaveInGlobalHandleMap(mp);
467475
} else {
Collapse file

‎src/node_errors.h‎

Copy file name to clipboardExpand all lines: src/node_errors.h
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ void PrintErrorString(const char* format, ...);
5252
V(ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST, TypeError) \
5353
V(ERR_MISSING_PASSPHRASE, TypeError) \
5454
V(ERR_MISSING_PLATFORM_FOR_WORKER, Error) \
55+
V(ERR_NON_CONTEXT_AWARE_DISABLED, Error) \
5556
V(ERR_MODULE_NOT_FOUND, Error) \
5657
V(ERR_OUT_OF_RANGE, RangeError) \
5758
V(ERR_SCRIPT_EXECUTION_INTERRUPTED, Error) \
@@ -96,6 +97,8 @@ void PrintErrorString(const char* format, ...);
9697
V(ERR_MISSING_PLATFORM_FOR_WORKER, \
9798
"The V8 platform used by this instance of Node does not support " \
9899
"creating Workers") \
100+
V(ERR_NON_CONTEXT_AWARE_DISABLED, \
101+
"Loading non context-aware native modules has been disabled") \
99102
V(ERR_SCRIPT_EXECUTION_INTERRUPTED, \
100103
"Script execution was interrupted by `SIGINT`") \
101104
V(ERR_TRANSFERRING_EXTERNALIZED_SHAREDARRAYBUFFER, \
Collapse file

‎src/node_options.cc‎

Copy file name to clipboardExpand all lines: src/node_options.cc
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,10 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
385385
"silence all process warnings",
386386
&EnvironmentOptions::no_warnings,
387387
kAllowedInEnvironment);
388+
AddOption("--force-context-aware",
389+
"disable loading non-context-aware addons",
390+
&EnvironmentOptions::force_context_aware,
391+
kAllowedInEnvironment);
388392
AddOption("--pending-deprecation",
389393
"emit pending deprecation warnings",
390394
&EnvironmentOptions::pending_deprecation,
Collapse file

‎src/node_options.h‎

Copy file name to clipboardExpand all lines: src/node_options.h
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ class EnvironmentOptions : public Options {
116116
bool no_deprecation = false;
117117
bool no_force_async_hooks_checks = false;
118118
bool no_warnings = false;
119+
bool force_context_aware = false;
119120
bool pending_deprecation = false;
120121
bool preserve_symlinks = false;
121122
bool preserve_symlinks_main = false;

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.