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

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