diff --git a/plugins/sudoers/regress/sudoers/test8.toke.ok b/plugins/sudoers/regress/sudoers/test8.toke.ok index 4b39d04fd..f77564529 100644 --- a/plugins/sudoers/regress/sudoers/test8.toke.ok +++ b/plugins/sudoers/regress/sudoers/test8.toke.ok @@ -4,4 +4,4 @@ USERALIAS ALIAS = BEGINSTR STRBODY STRBODY ENDSTR WORD(4) USERALIAS ALIAS = WORD(6) # -USERALIAS ALIAS = BEGINSTR STRBODY <*> ERROR ERROR \ No newline at end of file +USERALIAS ALIAS = BEGINSTR STRBODY <*> ERROR diff --git a/plugins/sudoers/toke.c b/plugins/sudoers/toke.c index 25bb04665..76dde33cb 100644 --- a/plugins/sudoers/toke.c +++ b/plugins/sudoers/toke.c @@ -3962,6 +3962,9 @@ YY_RULE_SETUP #line 760 "toke.l" { if (YY_START == INSTR) { + /* re-scan after changing state */ + BEGIN INITIAL; + sudoersless(0); sudoerserror("unexpected line break in string"); LEXTRACE("ERROR "); return ERROR; @@ -3975,7 +3978,7 @@ YY_RULE_SETUP YY_BREAK case 77: YY_RULE_SETUP -#line 773 "toke.l" +#line 776 "toke.l" { /* throw away space/tabs */ sawspace = true; /* but remember for fill_args */ } @@ -3983,7 +3986,7 @@ YY_RULE_SETUP case 78: /* rule 78 can match eol */ YY_RULE_SETUP -#line 777 "toke.l" +#line 780 "toke.l" { sawspace = true; /* remember for fill_args */ sudolineno++; @@ -3993,7 +3996,7 @@ YY_RULE_SETUP case 79: /* rule 79 can match eol */ YY_RULE_SETUP -#line 783 "toke.l" +#line 786 "toke.l" { if (sudoerstext[sudoersleng - 1] == '\n') { /* comment ending in a newline */ @@ -4011,7 +4014,7 @@ YY_RULE_SETUP YY_BREAK case 80: YY_RULE_SETUP -#line 798 "toke.l" +#line 801 "toke.l" { LEXTRACE("NOMATCH "); return NOMATCH; @@ -4026,9 +4029,13 @@ case YY_STATE_EOF(INSTR): case YY_STATE_EOF(WANTDIGEST): case YY_STATE_EOF(GOTINC): case YY_STATE_EOF(EXPECTPATH): -#line 803 "toke.l" +#line 806 "toke.l" { if (YY_START != INITIAL) { + if (YY_START == INSTR) + sudoerserror("unterminated string"); + else + sudoerserror("unexpected state at EOF"); BEGIN INITIAL; LEXTRACE("ERROR "); return ERROR; @@ -4039,10 +4046,10 @@ case YY_STATE_EOF(EXPECTPATH): YY_BREAK case 81: YY_RULE_SETUP -#line 813 "toke.l" +#line 820 "toke.l" ECHO; YY_BREAK -#line 4040 "toke.c" +#line 4047 "toke.c" case YY_END_OF_BUFFER: { @@ -5003,7 +5010,7 @@ void sudoersfree (void * ptr ) #define YYTABLES_NAME "yytables" -#line 813 "toke.l" +#line 820 "toke.l" struct path_list { diff --git a/plugins/sudoers/toke.l b/plugins/sudoers/toke.l index 8cda9ab89..4ae3bbf85 100644 --- a/plugins/sudoers/toke.l +++ b/plugins/sudoers/toke.l @@ -759,6 +759,9 @@ sudoedit { <*>\r?\n { if (YY_START == INSTR) { + /* re-scan after changing state */ + BEGIN INITIAL; + sudoersless(0); sudoerserror("unexpected line break in string"); LEXTRACE("ERROR "); return ERROR; @@ -802,6 +805,10 @@ sudoedit { <*><> { if (YY_START != INITIAL) { + if (YY_START == INSTR) + sudoerserror("unterminated string"); + else + sudoerserror("unexpected state at EOF"); BEGIN INITIAL; LEXTRACE("ERROR "); return ERROR;