Print a more sensible error if yyparse() returns non-zero but

yyerror() was not called.
This commit is contained in:
Todd C. Miller
2012-01-04 15:45:03 -05:00
parent a1815e17ca
commit 0f5eaa17fd
3 changed files with 8 additions and 4 deletions

View File

@@ -118,8 +118,12 @@ sudo_file_parse(struct sudo_nss *nss)
init_parser(sudoers_file, 0);
yyin = nss->handle;
if (yyparse() != 0 || parse_error) {
log_error(NO_EXIT, _("parse error in %s near line %d"),
errorfile, errorlineno);
if (errorlineno != -1) {
log_error(NO_EXIT, _("parse error in %s near line %d"),
errorfile, errorlineno);
} else {
log_error(NO_EXIT, _("parse error in %s"), errorfile);
}
debug_return_int(-1);
}
debug_return_int(0);