2
0
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:
Todd C. Miller
2016-10-26 11:22:30 -06:00
parent 63adb21cea
commit 4c8988d483

View File

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