]> granicus.if.org Git - sudo/commitdiff
Use bitwise AND instead of modulus to check for length being odd.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Sun, 27 Mar 2011 21:16:15 +0000 (17:16 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Sun, 27 Mar 2011 21:16:15 +0000 (17:16 -0400)
A newline in the middle of a string is an error unless a line
continuation character is used.

--HG--
branch : 1.7

toke.c
toke.l

diff --git a/toke.c b/toke.c
index ebd7a93aed15587089a67878d8613e4c15ac92b3..f6e8b8879b416f75b2340945cfcd323cdbdfb7dd 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -2340,7 +2340,7 @@ case 50:
 YY_RULE_SETUP
 #line 562 "toke.l"
 {
-                           if (yyleng % 2 == 1)
+                           if (yyleng & 1)
                                return '!';     /* return '!' */
                        }
        YY_BREAK
@@ -2348,6 +2348,10 @@ case 51:
 YY_RULE_SETUP
 #line 567 "toke.l"
 {
+                           if (YY_START == INSTR) {
+                               LEXTRACE("ERROR ");
+                               return ERROR;   /* line break in string */
+                           }
                            BEGIN INITIAL;
                            ++sudolineno;
                            continued = FALSE;
@@ -2357,14 +2361,14 @@ YY_RULE_SETUP
        YY_BREAK
 case 52:
 YY_RULE_SETUP
-#line 575 "toke.l"
+#line 579 "toke.l"
 {                      /* throw away space/tabs */
                            sawspace = TRUE;    /* but remember for fill_args */
                        }
        YY_BREAK
 case 53:
 YY_RULE_SETUP
-#line 579 "toke.l"
+#line 583 "toke.l"
 {
                            sawspace = TRUE;    /* remember for fill_args */
                            ++sudolineno;
@@ -2373,7 +2377,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 54:
 YY_RULE_SETUP
-#line 585 "toke.l"
+#line 589 "toke.l"
 {
                            BEGIN INITIAL;
                            ++sudolineno;
@@ -2384,7 +2388,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 55:
 YY_RULE_SETUP
-#line 593 "toke.l"
+#line 597 "toke.l"
 {
                            LEXTRACE("ERROR ");
                            return ERROR;
@@ -2396,7 +2400,7 @@ case YY_STATE_EOF(GOTCMND):
 case YY_STATE_EOF(STARTDEFS):
 case YY_STATE_EOF(INDEFS):
 case YY_STATE_EOF(INSTR):
-#line 598 "toke.l"
+#line 602 "toke.l"
 {
                            if (YY_START != INITIAL) {
                                BEGIN INITIAL;
@@ -2409,10 +2413,10 @@ case YY_STATE_EOF(INSTR):
        YY_BREAK
 case 56:
 YY_RULE_SETUP
-#line 608 "toke.l"
+#line 612 "toke.l"
 ECHO;
        YY_BREAK
-#line 2415 "lex.yy.c"
+#line 2419 "lex.yy.c"
 
        case YY_END_OF_BUFFER:
                {
@@ -3303,7 +3307,7 @@ int main()
        return 0;
        }
 #endif
-#line 608 "toke.l"
+#line 612 "toke.l"
 
 struct path_list {
     char *path;
diff --git a/toke.l b/toke.l
index f9b49f85bc286ba587707ac9e99510ea49fab9f7..ee56a6d04f7f99dad1fd410711ce5e8b7a8ed398 100644 (file)
--- a/toke.l
+++ b/toke.l
@@ -560,11 +560,15 @@ sudoedit          {
                        }                       /* return ':' */
 
 <*>!+                  {
-                           if (yyleng % 2 == 1)
+                           if (yyleng & 1)
                                return '!';     /* return '!' */
                        }
 
 <*>\n                  {
+                           if (YY_START == INSTR) {
+                               LEXTRACE("ERROR ");
+                               return ERROR;   /* line break in string */
+                           }
                            BEGIN INITIAL;
                            ++sudolineno;
                            continued = FALSE;