Skip to content

Commit 8be6702

Browse files
sam-githubitaloacasas
authored andcommitted
src: add SafeGetenv() to internal API
Allow it to be used anywhere in src/ that env variables with security implications are accessed. PR-URL: #11006 Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
1 parent a8613f8 commit 8be6702

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/node.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ Local<Value> UVException(Isolate* isolate,
901901

902902

903903
// Look up environment variable unless running as setuid root.
904-
inline bool SafeGetenv(const char* key, std::string* text) {
904+
bool SafeGetenv(const char* key, std::string* text) {
905905
#ifndef _WIN32
906906
// TODO(bnoordhuis) Should perhaps also check whether getauxval(AT_SECURE)
907907
// is non-zero on Linux.

src/node_internals.h

+2
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ void RegisterSignalHandler(int signal,
108108
bool reset_handler = false);
109109
#endif
110110

111+
bool SafeGetenv(const char* key, std::string* text);
112+
111113
template <typename T, size_t N>
112114
constexpr size_t arraysize(const T(&)[N]) { return N; }
113115

0 commit comments

Comments
 (0)