Don't close fp in sudoers_parse_ldif()

The caller should be the one to handle this.
This commit is contained in:
Todd C. Miller
2021-02-02 15:06:38 -07:00
parent 68939adee2
commit aaa2e8ddec
2 changed files with 9 additions and 7 deletions

View File

@@ -609,16 +609,21 @@ parse_ldif(struct sudoers_parse_tree *parse_tree, const char *input_file,
struct cvtsudoers_config *conf)
{
FILE *fp = stdin;
bool ret = false;
debug_decl(parse_ldif, SUDOERS_DEBUG_UTIL);
/* Open LDIF file and parse it. */
if (strcmp(input_file, "-") != 0) {
if ((fp = fopen(input_file, "r")) == NULL)
sudo_fatal(U_("unable to open %s"), input_file);
sudo_warn(U_("unable to open %s"), input_file);
}
debug_return_bool(sudoers_parse_ldif(parse_tree, fp, conf->sudoers_base,
conf->store_options));
if (fp != NULL) {
ret = sudoers_parse_ldif(parse_tree, fp, conf->sudoers_base,
conf->store_options);
if (fp != stdin)
fclose(fp);
}
debug_return_bool(ret);
}
static bool

View File

@@ -775,8 +775,5 @@ sudoers_parse_ldif(struct sudoers_parse_tree *parse_tree,
rbdestroy(groupcache, str_list_free);
rbdestroy(hostcache, str_list_free);
if (fp != stdin)
fclose(fp);
debug_return_bool(errors == 0);
}