From: Todd C. Miller Date: Wed, 4 Jan 2012 20:45:03 +0000 (-0500) Subject: Print a more sensible error if yyparse() returns non-zero but X-Git-Tag: SUDO_1_8_4~93^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0f5eaa17fd1903663228e34db2d62e8672bc0e37;p=sudo Print a more sensible error if yyparse() returns non-zero but yyerror() was not called. --- diff --git a/plugins/sudoers/gram.c b/plugins/sudoers/gram.c index 1ae4ecc68..e8fe89761 100644 --- a/plugins/sudoers/gram.c +++ b/plugins/sudoers/gram.c @@ -822,7 +822,7 @@ init_parser(const char *path, int quiet) parse_error = false; errorlineno = -1; - errorfile = NULL; + errorfile = sudoers; verbose = !quiet; debug_return; diff --git a/plugins/sudoers/gram.y b/plugins/sudoers/gram.y index 3b64fc4ca..74ab37311 100644 --- a/plugins/sudoers/gram.y +++ b/plugins/sudoers/gram.y @@ -791,7 +791,7 @@ init_parser(const char *path, int quiet) parse_error = false; errorlineno = -1; - errorfile = NULL; + errorfile = sudoers; verbose = !quiet; debug_return; diff --git a/plugins/sudoers/parse.c b/plugins/sudoers/parse.c index 6d0393830..ad1ad70db 100644 --- a/plugins/sudoers/parse.c +++ b/plugins/sudoers/parse.c @@ -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);