Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 68f698c

Browse filesBrowse files
sam-githubMylesBorins
authored andcommitted
src: use SafeGetenv() for NODE_REDIRECT_WARNINGS
Mutations of the environment can invalidate pointers to environment variables, so make `secure_getenv()` copy them out instead of returning pointers. This is the part of #11051 that applies to be11fb4. This part wasn't backported to 6.x when #11051 was backported because the semver-minor introduction of NODE_REDIRECT_WARNINGS hadn't been backported yet. Now that the env var is backported, this last bit of #11051 is needed. PR-URL: #12677 Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
1 parent 16802c0 commit 68f698c
Copy full SHA for 68f698c

File tree

Expand file treeCollapse file tree

3 files changed

+8
-8
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+8
-8
lines changed
Open diff view settings
Collapse file

‎src/node.cc‎

Copy file name to clipboardExpand all lines: src/node.cc
+3-4Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ bool config_preserve_symlinks = false;
207207
bool config_expose_internals = false;
208208

209209
// Set in node.cc by ParseArgs when --redirect-warnings= is used.
210-
const char* config_warning_file;
210+
std::string config_warning_file; // NOLINT(runtime/string)
211211

212212
// process-relative uptime base, initialized at start-up
213213
static double prog_start_time;
@@ -4410,9 +4410,8 @@ void Init(int* argc,
44104410
if (openssl_config.empty())
44114411
SafeGetenv("OPENSSL_CONF", &openssl_config);
44124412

4413-
if (auto redirect_warnings = secure_getenv("NODE_REDIRECT_WARNINGS")) {
4414-
config_warning_file = redirect_warnings;
4415-
}
4413+
if (config_warning_file.empty())
4414+
SafeGetenv("NODE_REDIRECT_WARNINGS", &config_warning_file);
44164415

44174416
// Parse a few arguments which are specific to Node.
44184417
int v8_argc;
Collapse file

‎src/node_config.cc‎

Copy file name to clipboardExpand all lines: src/node_config.cc
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,12 @@ void InitConfig(Local<Object> target,
4949
if (config_expose_internals)
5050
READONLY_BOOLEAN_PROPERTY("exposeInternals");
5151

52-
if (config_warning_file != nullptr) {
52+
if (!config_warning_file.empty()) {
5353
Local<String> name = OneByteString(env->isolate(), "warningFile");
5454
Local<String> value = String::NewFromUtf8(env->isolate(),
55-
config_warning_file,
56-
v8::NewStringType::kNormal)
55+
config_warning_file.data(),
56+
v8::NewStringType::kNormal,
57+
config_warning_file.size())
5758
.ToLocalChecked();
5859
target->DefineOwnProperty(env->context(), name, value).FromJust();
5960
}
Collapse file

‎src/node_internals.h‎

Copy file name to clipboardExpand all lines: src/node_internals.h
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ extern bool config_expose_internals;
5252
// Set in node.cc by ParseArgs when --redirect-warnings= is used.
5353
// Used to redirect warning output to a file rather than sending
5454
// it to stderr.
55-
extern const char* config_warning_file;
55+
extern std::string config_warning_file;
5656

5757
// Forward declaration
5858
class Environment;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.