Make a copy of the current sudoers path when assigning errorfile.
Fixes a potential use after free in visudo when there is an error in one of the include files.
This commit is contained in:
@@ -1030,7 +1030,9 @@ export_sudoers(const char *sudoers_path, const char *export_path,
|
||||
if (!quiet)
|
||||
sudo_warnx(U_("failed to parse %s file, unknown error"), sudoers_path);
|
||||
parse_error = true;
|
||||
errorfile = sudoers_path;
|
||||
free(errorfile);
|
||||
if ((errorfile = strdup(sudoers_path)) == NULL)
|
||||
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
}
|
||||
ret = !parse_error;
|
||||
|
||||
|
Reference in New Issue
Block a user