Skip to content

Commit

Permalink
src: add SafeGetenv() to internal API
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
sam-github authored and italoacasas committed Feb 22, 2017
1 parent a8613f8 commit 8be6702
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ Local<Value> UVException(Isolate* isolate,


// Look up environment variable unless running as setuid root.
inline bool SafeGetenv(const char* key, std::string* text) {
bool SafeGetenv(const char* key, std::string* text) {
#ifndef _WIN32
// TODO(bnoordhuis) Should perhaps also check whether getauxval(AT_SECURE)
// is non-zero on Linux.
Expand Down
2 changes: 2 additions & 0 deletions src/node_internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ void RegisterSignalHandler(int signal,
bool reset_handler = false);
#endif

bool SafeGetenv(const char* key, std::string* text);

template <typename T, size_t N>
constexpr size_t arraysize(const T(&)[N]) { return N; }

Expand Down

0 comments on commit 8be6702

Please sign in to comment.