]> granicus.if.org Git - sudo/commitdiff
Print a more sensible error if yyparse() returns non-zero but
authorTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 12 Jan 2012 20:20:47 +0000 (15:20 -0500)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 12 Jan 2012 20:20:47 +0000 (15:20 -0500)
yyerror() was not called.

--HG--
branch : 1.7

gram.c
gram.y
parse.c

diff --git a/gram.c b/gram.c
index 8e9eee458777233d67f8dd1645fef4262cb916c8..b20f95150eb1c178ea72792259664033896ad8d7 100644 (file)
--- 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 225fd20dca0f9fdb1b3498b0c49eb301fc148ec7..92a75cf6bd7ec7a9d9f223be9acba11820b7765a 100644 (file)
--- 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 30eb7f4d3cd5291853df49153b248ddac6cd676e..bfd6a6cf52a29753779e8db1a520938222af9f82 100644 (file)
--- 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;