You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

225 lines
3.8 KiB

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