Browse Source

src: add SafeGetenv() to internal API

Allow it to be used anywhere in src/ that env variables with security
implications are accessed.
v6
Sam Roberts 8 years ago
parent
commit
901e926d43
  1. 2
      src/node.cc
  2. 2
      src/node_internals.h

2
src/node.cc

@ -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.

2
src/node_internals.h

@ -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; }

Loading…
Cancel
Save