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

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