Use non-exiting allocators in the redblack tree and fix the fallout.

Also switch to non-exiting allocators in affected code blocks.
This commit is contained in:
Todd C. Miller
2015-05-27 09:51:54 -06:00
parent 46770c9588
commit 2bf454b74d
12 changed files with 194 additions and 77 deletions

View File

@@ -844,12 +844,13 @@ add_userspec(struct member *members, struct privilege *privs)
* Free up space used by data structures from a previous parser run and sets
* the current sudoers file to path.
*/
void
bool
init_parser(const char *path, bool quiet)
{
struct member_list *binding;
struct defaults *d, *d_next;
struct userspec *us, *us_next;
bool rval = true;
debug_decl(init_parser, SUDOERS_DEBUG_PARSER)
TAILQ_FOREACH_SAFE(us, &userspecs, entries, us_next) {
@@ -954,21 +955,31 @@ init_parser(const char *path, bool quiet)
}
TAILQ_INIT(&defaults);
init_aliases();
init_lexer();
sudo_efree(sudoers);
sudoers = path ? sudo_estrdup(path) : NULL;
if (!init_aliases()) {
sudo_warnx(U_("unable to allocate memory"));
rval = false;
}
free(sudoers);
if (path != NULL) {
if ((sudoers = strdup(path)) == NULL) {
sudo_warnx(U_("unable to allocate memory"));
rval = false;
}
} else {
sudoers = NULL;
}
parse_error = false;
errorlineno = -1;
errorfile = sudoers;
sudoers_warnings = !quiet;
debug_return;
debug_return_bool(rval);
}
#line 919 "gram.c"
#line 930 "gram.c"
/* allocate initial stack or double stack size, up to YYMAXDEPTH */
#if defined(__cplusplus) || defined(__STDC__)
static int yygrowstack(void)
@@ -1877,7 +1888,7 @@ case 113:
yyval.member = new_member(yyvsp[0].string, WORD);
}
break;
#line 1828 "gram.c"
#line 1839 "gram.c"
}
yyssp -= yym;
yystate = *yyssp;