mirror of
https://github.com/sudo-project/sudo.git
synced 2025-08-31 06:15:37 +00:00
When checking for old-style bash functions in the environment, check
for values starting with "() " (note the trailing space) rather than "()". Bash will only treat the value as a function if the space after "()" is present. The trailing space was already present in the compare string but when it was added, the length passed to strncmp() was not updated from 3 to 4. Found by PVS-Studio. No security impact.
This commit is contained in:
@@ -715,7 +715,7 @@ env_should_delete(const char *var)
|
||||
|
||||
/* Skip variables with values beginning with () (bash functions) */
|
||||
if ((cp = strchr(var, '=')) != NULL) {
|
||||
if (strncmp(cp, "=() ", 3) == 0) {
|
||||
if (strncmp(cp, "=() ", 4) == 0) {
|
||||
delete_it = true;
|
||||
goto done;
|
||||
}
|
||||
@@ -750,7 +750,7 @@ env_should_keep(const char *var)
|
||||
/* Skip bash functions unless we matched on the value as well as name. */
|
||||
if (keepit && !full_match) {
|
||||
if ((cp = strchr(var, '=')) != NULL) {
|
||||
if (strncmp(cp, "=() ", 3) == 0)
|
||||
if (strncmp(cp, "=() ", 4) == 0)
|
||||
keepit = false;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user