Blame SOURCES/autofs-5.1.0-fix-reset-amd-lexer-scan-buffer.patch

304803
autofs-5.1.0 - fix reset amd lexer scan buffer
304803
304803
From: Ian Kent <ikent@redhat.com>
304803
304803
When the amd parser encounters an error often the lexer is left in
304803
a state where a new parse can't be started. Fix this by explicitly
304803
naming our start states and resetting to the proper start state at
304803
buffer initialization on each scan.
304803
---
304803
 CHANGELOG           |    1 
304803
 modules/amd_tok.l   |   59 +++++++++++++++++++++++++++++++---------------------
304803
 modules/parse_amd.c |    3 ++
304803
 3 files changed, 40 insertions(+), 23 deletions(-)
304803
304803
--- autofs-5.0.7.orig/CHANGELOG
304803
+++ autofs-5.0.7/CHANGELOG
304803
@@ -152,6 +152,7 @@
304803
 - fix memory leak in get_exports().
304803
 - fix memory leak in get_defaults_entry().
304803
 - fix out of order clearing of options buffer.
304803
+- fix reset amd lexer scan buffer.
304803
 
304803
 25/07/2012 autofs-5.0.7
304803
 =======================
304803
--- autofs-5.0.7.orig/modules/amd_tok.l
304803
+++ autofs-5.0.7/modules/amd_tok.l
304803
@@ -1,4 +1,3 @@
304803
-%{
304803
 /* ----------------------------------------------------------------------- *
304803
  *
304803
  *  Copyright 2013 Ian Kent <raven@themaw.net>
304803
@@ -18,6 +17,12 @@
304803
  *
304803
  * ----------------------------------------------------------------------- */
304803
 
304803
+%s START MAPOPTVAL FSOPTVAL MNTOPTVAL SELOPTVAL SELARGVAL
304803
+
304803
+%{
304803
+
304803
+static int reset_start_state = 0;
304803
+
304803
 #ifdef ECHO
304803
 # undef ECHO
304803
 #endif
304803
@@ -71,8 +76,6 @@ int amd_yyinput(char *, int);
304803
 
304803
 %option nounput
304803
 
304803
-%x MAPOPTVAL FSOPTVAL MNTOPTVAL SELOPTVAL SELARGVAL
304803
-
304803
 NL		\r?\n
304803
 OPTWS		[[:blank:]]*
304803
 OTHR		[^!;:=/|\- \t\r\n#]*
304803
@@ -120,7 +123,14 @@ CUTSEP		(\|\||\/)
304803
 
304803
 %%
304803
 
304803
-<INITIAL>{
304803
+%{
304803
+	if (reset_start_state) {
304803
+		BEGIN START;
304803
+		reset_start_state = 0;
304803
+	}
304803
+%}
304803
+
304803
+<START>{
304803
 	{NL} |
304803
 	\x00 { }
304803
 
304803
@@ -179,23 +189,23 @@ CUTSEP		(\|\||\/)
304803
 
304803
 <MAPOPTVAL>{
304803
 	{NL} {
304803
-		BEGIN(INITIAL);
304803
+		BEGIN(START);
304803
 		yyless(1);
304803
 	}
304803
 
304803
 	\x00 {
304803
-		BEGIN(INITIAL);
304803
+		BEGIN(START);
304803
 		return SEPERATOR;
304803
 		yyless(1);
304803
 	}
304803
 
304803
 	";" {
304803
-		BEGIN(INITIAL);
304803
+		BEGIN(START);
304803
 		return SEPERATOR;
304803
 	}
304803
 
304803
 	{OPTWS} {
304803
-		BEGIN(INITIAL);
304803
+		BEGIN(START);
304803
 		return SPACE;
304803
 	}
304803
 
304803
@@ -224,23 +234,23 @@ CUTSEP		(\|\||\/)
304803
 
304803
 <FSOPTVAL>{
304803
 	{NL} {
304803
-		BEGIN(INITIAL);
304803
+		BEGIN(START);
304803
 		yyless(1);
304803
 	}
304803
 
304803
 	\x00 {
304803
-		BEGIN(INITIAL);
304803
+		BEGIN(START);
304803
 		return SEPERATOR;
304803
 		yyless(1);
304803
 	}
304803
 
304803
 	";" {
304803
-		BEGIN(INITIAL);
304803
+		BEGIN(START);
304803
 		return SEPERATOR;
304803
 	}
304803
 
304803
 	{OPTWS} {
304803
-		BEGIN(INITIAL);
304803
+		BEGIN(START);
304803
 		return SPACE;
304803
 	}
304803
 
304803
@@ -254,23 +264,23 @@ CUTSEP		(\|\||\/)
304803
 
304803
 <MNTOPTVAL>{
304803
 	{NL} {
304803
-		BEGIN(INITIAL);
304803
+		BEGIN(START);
304803
 		yyless(1);
304803
 	}
304803
 
304803
 	\x00 {
304803
-		BEGIN(INITIAL);
304803
+		BEGIN(START);
304803
 		return SEPERATOR;
304803
 		yyless(1);
304803
 	}
304803
 
304803
 	";" {
304803
-		BEGIN(INITIAL);
304803
+		BEGIN(START);
304803
 		return SEPERATOR;
304803
 	}
304803
 
304803
 	{OPTWS} {
304803
-		BEGIN(INITIAL);
304803
+		BEGIN(START);
304803
 		return SPACE;
304803
 	}
304803
 
304803
@@ -286,23 +296,23 @@ CUTSEP		(\|\||\/)
304803
 
304803
 <SELOPTVAL>{
304803
 	{NL} {
304803
-		BEGIN(INITIAL);
304803
+		BEGIN(START);
304803
 		yyless(1);
304803
 	}
304803
 
304803
 	\x00 {
304803
-		BEGIN(INITIAL);
304803
+		BEGIN(START);
304803
 		return SEPERATOR;
304803
 		yyless(1);
304803
 	}
304803
 
304803
 	";" {
304803
-		BEGIN(INITIAL);
304803
+		BEGIN(START);
304803
 		return SEPERATOR;
304803
 	}
304803
 
304803
 	{OPTWS} {
304803
-		BEGIN(INITIAL);
304803
+		BEGIN(START);
304803
 		return SPACE;
304803
 	}
304803
 
304803
@@ -318,18 +328,18 @@ CUTSEP		(\|\||\/)
304803
 
304803
 <SELARGVAL>{
304803
 	{NL} {
304803
-		BEGIN(INITIAL);
304803
+		BEGIN(START);
304803
 		yyless(1);
304803
 	}
304803
 
304803
 	\x00 {
304803
-		BEGIN(INITIAL);
304803
+		BEGIN(START);
304803
 		return SEPERATOR;
304803
 		yyless(1);
304803
 	}
304803
 
304803
 	";" {
304803
-		BEGIN(INITIAL);
304803
+		BEGIN(START);
304803
 		return SEPERATOR;
304803
 	}
304803
 
304803
@@ -391,6 +401,9 @@ static void amd_echo(void)
304803
 
304803
 void amd_set_scan_buffer(const char *buffer)
304803
 {
304803
+	YY_FLUSH_BUFFER;
304803
+	reset_start_state = 1;
304803
+
304803
 	line = buffer;
304803
 	line_pos = &line[0];
304803
 	/*
304803
--- autofs-5.0.7.orig/modules/parse_amd.c
304803
+++ autofs-5.0.7/modules/parse_amd.c
304803
@@ -1798,6 +1798,9 @@ static struct amd_entry *get_defaults_en
304803
 		if (!expand_selectors(ap, defaults, &expand, sv))
304803
 			goto out;
304803
 		if (amd_parse_list(ap, expand, &dflts, &sv)) {
304803
+			error(ap->logopt, MODPREFIX
304803
+			     "failed to parse defaults entry, "
304803
+			     "attempting to use internal default");
304803
 			free(expand);
304803
 			goto out;
304803
 		}