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.
  • Loading branch information
sam-github committed Feb 9, 2017
1 parent 46edd94 commit 901e926
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 @@ -924,7 +924,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 @@ -114,6 +114,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 901e926

Please sign in to comment.