Merge "Use foreach loop to match setuid unsafe env vars."
This commit is contained in:
commit
cf92ebcfe3
@ -237,7 +237,7 @@ static bool __is_valid_environment_variable(const char* name) {
|
|||||||
|
|
||||||
static bool __is_unsafe_environment_variable(const char* name) {
|
static bool __is_unsafe_environment_variable(const char* name) {
|
||||||
// None of these should be allowed in setuid programs.
|
// None of these should be allowed in setuid programs.
|
||||||
static const char* const UNSAFE_VARIABLE_NAMES[] = {
|
static constexpr const char* UNSAFE_VARIABLE_NAMES[] = {
|
||||||
"GCONV_PATH",
|
"GCONV_PATH",
|
||||||
"GETCONF_DIR",
|
"GETCONF_DIR",
|
||||||
"HOSTALIASES",
|
"HOSTALIASES",
|
||||||
@ -265,10 +265,9 @@ static bool __is_unsafe_environment_variable(const char* name) {
|
|||||||
"RES_OPTIONS",
|
"RES_OPTIONS",
|
||||||
"TMPDIR",
|
"TMPDIR",
|
||||||
"TZDIR",
|
"TZDIR",
|
||||||
nullptr
|
|
||||||
};
|
};
|
||||||
for (size_t i = 0; UNSAFE_VARIABLE_NAMES[i] != nullptr; ++i) {
|
for (const auto& unsafe_variable_name : UNSAFE_VARIABLE_NAMES) {
|
||||||
if (env_match(name, UNSAFE_VARIABLE_NAMES[i]) != nullptr) {
|
if (env_match(name, unsafe_variable_name) != nullptr) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user