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: nodejs#11006
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
  • Loading branch information
sam-github committed Apr 17, 2017
1 parent 6765c88 commit 0dc1d85
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 @@ -943,7 +943,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 @@ -112,6 +112,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 0dc1d85

Please sign in to comment.