From: Todd C. Miller Date: Thu, 12 Jan 2012 20:20:47 +0000 (-0500) Subject: Print a more sensible error if yyparse() returns non-zero but X-Git-Tag: SUDO_1_7_9~33 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=78ce8bb773266a3c63ee5dd9e196e8dedab04850;p=sudo Print a more sensible error if yyparse() returns non-zero but yyerror() was not called. --HG-- branch : 1.7 --- diff --git a/gram.c b/gram.c index 8e9eee458..b20f95150 100644 --- a/gram.c +++ b/gram.c @@ -826,7 +826,7 @@ init_parser(path, quiet) parse_error = FALSE; errorlineno = -1; - errorfile = NULL; + errorfile = sudoers; verbose = !quiet; } #line 780 "y.tab.c" diff --git a/gram.y b/gram.y index 225fd20dc..92a75cf6b 100644 --- a/gram.y +++ b/gram.y @@ -795,6 +795,6 @@ init_parser(path, quiet) parse_error = FALSE; errorlineno = -1; - errorfile = NULL; + errorfile = sudoers; verbose = !quiet; } diff --git a/parse.c b/parse.c index 30eb7f4d3..bfd6a6cf5 100644 --- a/parse.c +++ b/parse.c @@ -115,8 +115,12 @@ sudo_file_parse(nss) init_parser(_PATH_SUDOERS, 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); + } return -1; } return 0;