Browse Source

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 <michael_dawson@ca.ibm.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
v6.x
Sam Roberts 8 years ago
committed by Myles Borins
parent
commit
aec7ae2e67
No known key found for this signature in database GPG Key ID: 933B01F40B5CA946
  1. 2
      src/node.cc
  2. 2
      src/node_internals.h

2
src/node.cc

@ -945,7 +945,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

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

Loading…
Cancel
Save