prepare to upload
[debian/sudo] / toke.c
diff --git a/toke.c b/toke.c
index a4bcb8eaa53d73d2a25ea2f43919d32221981fd0..5f2b6392ccdb6be3188427e203d139d10f58fdd5 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -3,7 +3,7 @@
 /* A lexical scanner generated by flex */
 
 /* Scanner skeleton version:
- * $Header: /home/cvs/courtesan/sudo/toke.c,v 1.36 2009/05/27 00:47:17 millert Exp $
+ * $Header: /home/cvs/openbsd/src/usr.bin/lex/flex.skl,v 1.10 2007/01/26 14:38:19 tsi Exp $
  */
 
 #define FLEX_SCANNER
@@ -1416,11 +1416,8 @@ char *yytext;
 #include "parse.h"
 #include <gram.h>
 
-#ifndef lint
-__unused static const char rcsid[] = "$Sudo: toke.c,v 1.36 2009/05/27 00:47:17 millert Exp $";
-#endif /* lint */
-
 extern YYSTYPE yylval;
+extern int parse_error;
 int sudolineno = 1;
 char *sudoers;
 static int sawspace = 0;
@@ -1461,7 +1458,7 @@ extern void yyerror               __P((const char *));
 
 #define INSTR 5
 
-#line 1465 "lex.yy.c"
+#line 1462 "lex.yy.c"
 
 /* Macros after this point can all be overridden by user definitions in
  * section 1.
@@ -1615,9 +1612,9 @@ YY_DECL
        register char *yy_cp, *yy_bp;
        register int yy_act;
 
-#line 131 "toke.l"
+#line 128 "toke.l"
 
-#line 1621 "lex.yy.c"
+#line 1618 "lex.yy.c"
 
        if ( yy_init )
                {
@@ -1703,12 +1700,12 @@ do_action:      /* This label is used only to access EOF actions. */
 
 case 1:
 YY_RULE_SETUP
-#line 132 "toke.l"
+#line 129 "toke.l"
 BEGIN STARTDEFS;
        YY_BREAK
 case 2:
 YY_RULE_SETUP
-#line 134 "toke.l"
+#line 131 "toke.l"
 {
                            BEGIN INDEFS;
                            LEXTRACE("DEFVAR ");
@@ -1720,7 +1717,7 @@ YY_RULE_SETUP
 
 case 3:
 YY_RULE_SETUP
-#line 143 "toke.l"
+#line 140 "toke.l"
 {
                            BEGIN STARTDEFS;
                            LEXTRACE(", ");
@@ -1729,7 +1726,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 4:
 YY_RULE_SETUP
-#line 149 "toke.l"
+#line 146 "toke.l"
 {
                            LEXTRACE("= ");
                            return('=');
@@ -1737,7 +1734,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 5:
 YY_RULE_SETUP
-#line 154 "toke.l"
+#line 151 "toke.l"
 {
                            LEXTRACE("+= ");
                            return('+');
@@ -1745,7 +1742,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 6:
 YY_RULE_SETUP
-#line 159 "toke.l"
+#line 156 "toke.l"
 {
                            LEXTRACE("-= ");
                            return('-');
@@ -1753,7 +1750,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 7:
 YY_RULE_SETUP
-#line 164 "toke.l"
+#line 161 "toke.l"
 {
                            LEXTRACE("BEGINSTR ");
                            yylval.string = NULL;
@@ -1762,7 +1759,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 8:
 YY_RULE_SETUP
-#line 170 "toke.l"
+#line 167 "toke.l"
 {
                            LEXTRACE("WORD(2) ");
                            if (!fill(yytext, yyleng))
@@ -1774,7 +1771,7 @@ YY_RULE_SETUP
 
 case 9:
 YY_RULE_SETUP
-#line 179 "toke.l"
+#line 176 "toke.l"
 {
                            /* Line continuation char followed by newline. */
                            ++sudolineno;
@@ -1783,7 +1780,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 10:
 YY_RULE_SETUP
-#line 185 "toke.l"
+#line 182 "toke.l"
 {
                            LEXTRACE("ENDSTR ");
                            BEGIN INDEFS;
@@ -1792,7 +1789,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 11:
 YY_RULE_SETUP
-#line 191 "toke.l"
+#line 188 "toke.l"
 {
                            LEXTRACE("BACKSLASH ");
                            if (!append(yytext, yyleng))
@@ -1801,7 +1798,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 12:
 YY_RULE_SETUP
-#line 197 "toke.l"
+#line 194 "toke.l"
 {
                            LEXTRACE("STRBODY ");
                            if (!append(yytext, yyleng))
@@ -1812,7 +1809,7 @@ YY_RULE_SETUP
 
 case 13:
 YY_RULE_SETUP
-#line 205 "toke.l"
+#line 202 "toke.l"
 {
                            /* quoted fnmatch glob char, pass verbatim */
                            LEXTRACE("QUOTEDCHAR ");
@@ -1823,7 +1820,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 14:
 YY_RULE_SETUP
-#line 213 "toke.l"
+#line 210 "toke.l"
 {
                            /* quoted sudoers special char, strip backslash */
                            LEXTRACE("QUOTEDCHAR ");
@@ -1834,7 +1831,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 15:
 YY_RULE_SETUP
-#line 221 "toke.l"
+#line 218 "toke.l"
 {
                            BEGIN INITIAL;
                            yyless(0);
@@ -1843,7 +1840,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 16:
 YY_RULE_SETUP
-#line 227 "toke.l"
+#line 224 "toke.l"
 {
                            LEXTRACE("ARG ");
                            if (!fill_args(yytext, yyleng, sawspace))
@@ -1854,7 +1851,7 @@ YY_RULE_SETUP
 
 case 17:
 YY_RULE_SETUP
-#line 235 "toke.l"
+#line 232 "toke.l"
 {
                            char *path;
 
@@ -1870,7 +1867,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 18:
 YY_RULE_SETUP
-#line 248 "toke.l"
+#line 245 "toke.l"
 {
                            char *path;
 
@@ -1879,8 +1876,11 @@ YY_RULE_SETUP
 
                            LEXTRACE("INCLUDEDIR\n");
 
-                           /* Push current buffer and switch to include file */
-                           if (!push_includedir(path))
+                           /*
+                            * Push current buffer and switch to include file.
+                            * We simply ignore empty directories.
+                            */
+                           if (!push_includedir(path) && parse_error)
                                yyterminate();
                        }
        YY_BREAK
@@ -3369,7 +3369,7 @@ switch_dir(stack, dirpath)
 
     if (!(dir = opendir(dirpath))) {
        yyerror(dirpath);
-       return(FALSE);
+       return(NULL);
     }
     while ((dent = readdir(dir))) {
        /* Ignore files that end in '~' or have a '.' in them. */
@@ -3461,7 +3461,7 @@ init_lexer()
            efree(pl);
        }
        efree(istack[idepth].path);
-       if (!istack[idepth].keepopen)
+       if (idepth && !istack[idepth].keepopen)
            fclose(istack[idepth].bs->yy_input_file);
        yy_delete_buffer(istack[idepth].bs);
     }
@@ -3486,7 +3486,7 @@ _push_include(path, isdir)
        }
        istacksize += SUDOERS_STACK_INCREMENT;
        istack = (struct include_stack *) realloc(istack,
-           sizeof(istack) * istacksize);
+           sizeof(*istack) * istacksize);
        if (istack == NULL) {
            yyerror("unable to allocate memory");
            return(FALSE);
@@ -3494,12 +3494,12 @@ _push_include(path, isdir)
     }
     if (isdir) {
        if (!(path = switch_dir(&istack[idepth], path))) {
-           yyerror(path);
+           /* switch_dir() called yyerror() for us */
            return(FALSE);
        }
        if ((fp = open_sudoers(path, FALSE, &keepopen)) == NULL) {
            yyerror(path);
-           return(FALSE); /* XXX - just to go next one? */
+           return(FALSE); /* XXX - just to go next one */
        }
     } else {
        if ((fp = open_sudoers(path, TRUE, &keepopen)) == NULL) {
@@ -3539,7 +3539,7 @@ pop_include()
        istack[idepth - 1].more = pl->next;
        if ((fp = open_sudoers(pl->path, FALSE, &keepopen)) == NULL) {
            yyerror(pl->path);
-           return(FALSE); /* XXX - just to go next one? */
+           return(FALSE); /* XXX - just to go next one */
        }
        efree(sudoers);
        sudoers = pl->path;
@@ -3592,6 +3592,7 @@ parse_include(base)
                memcpy(pp, user_shost, shost_len);
                pp += shost_len;
                cp += 2;
+               continue;
            }
            *pp++ = *cp++;
        }