Fix a memory leak on error when including a file or directory.
This commit is contained in:
@@ -4572,6 +4572,7 @@ push_include_int(char *path, bool isdir)
|
||||
|
||||
if (idepth > MAX_SUDOERS_DEPTH) {
|
||||
sudoerserror(N_("too many levels of includes"));
|
||||
rcstr_delref(path);
|
||||
debug_return_bool(false);
|
||||
}
|
||||
istacksize += SUDOERS_STACK_INCREMENT;
|
||||
@@ -4579,6 +4580,7 @@ push_include_int(char *path, bool isdir)
|
||||
if (new_istack == NULL) {
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
sudoerserror(NULL);
|
||||
rcstr_delref(path);
|
||||
debug_return_bool(false);
|
||||
}
|
||||
istack = new_istack;
|
||||
@@ -4614,6 +4616,7 @@ push_include_int(char *path, bool isdir)
|
||||
}
|
||||
}
|
||||
/* A missing or insecure include dir is not a fatal error. */
|
||||
rcstr_delref(path);
|
||||
debug_return_bool(true);
|
||||
}
|
||||
count = switch_dir(&istack[idepth], path);
|
||||
@@ -4638,6 +4641,7 @@ push_include_int(char *path, bool isdir)
|
||||
if ((fp = open_sudoers(path, true, &keepopen)) == NULL) {
|
||||
/* The error was already printed by open_sudoers() */
|
||||
sudoerserror(NULL);
|
||||
rcstr_delref(path);
|
||||
debug_return_bool(false);
|
||||
}
|
||||
}
|
||||
|
@@ -933,6 +933,7 @@ push_include_int(char *path, bool isdir)
|
||||
|
||||
if (idepth > MAX_SUDOERS_DEPTH) {
|
||||
sudoerserror(N_("too many levels of includes"));
|
||||
rcstr_delref(path);
|
||||
debug_return_bool(false);
|
||||
}
|
||||
istacksize += SUDOERS_STACK_INCREMENT;
|
||||
@@ -940,6 +941,7 @@ push_include_int(char *path, bool isdir)
|
||||
if (new_istack == NULL) {
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
sudoerserror(NULL);
|
||||
rcstr_delref(path);
|
||||
debug_return_bool(false);
|
||||
}
|
||||
istack = new_istack;
|
||||
@@ -975,6 +977,7 @@ push_include_int(char *path, bool isdir)
|
||||
}
|
||||
}
|
||||
/* A missing or insecure include dir is not a fatal error. */
|
||||
rcstr_delref(path);
|
||||
debug_return_bool(true);
|
||||
}
|
||||
count = switch_dir(&istack[idepth], path);
|
||||
@@ -999,6 +1002,7 @@ push_include_int(char *path, bool isdir)
|
||||
if ((fp = open_sudoers(path, true, &keepopen)) == NULL) {
|
||||
/* The error was already printed by open_sudoers() */
|
||||
sudoerserror(NULL);
|
||||
rcstr_delref(path);
|
||||
debug_return_bool(false);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user