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

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