* [nft PATCH] scanner: fix reading of really long line
@ 2014-11-29 16:24 Eric Leblond
2014-12-01 11:55 ` Pablo Neira Ayuso
0 siblings, 1 reply; 4+ messages in thread
From: Eric Leblond @ 2014-11-29 16:24 UTC (permalink / raw)
To: pablo; +Cc: netfilter-devel, Eric Leblond
Current code is causing a failure in adding a set containing
a really long list of elements. The failure occurs as soon as
the line is longer than flex read buffer.
When a line is longer than scanner buffer size, the code in YY_INPUT
forces a rewind to the beginning of the string because it does not
find a end of line. The result is that the string is never parsed.
This patch updates the code by rewinding till we found a space.
Signed-off-by: Eric Leblond <eric@regit.org>
---
src/scanner.l | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/scanner.l b/src/scanner.l
index f0ed8d4..2fafa71 100644
--- a/src/scanner.l
+++ b/src/scanner.l
@@ -47,7 +47,8 @@
clearerr(yyin); \
} \
if (result > 1) { \
- while (result > 1 && buf[result - 1] != '\n') \
+ while (result > 1 && \
+ (buf[result - 1] != '\n' && buf[result - 1] != ' ')) \
result--, n++; \
result--, n++; \
fseek(yyin, -n, SEEK_CUR); \
--
2.1.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [nft PATCH] scanner: fix reading of really long line
2014-11-29 16:24 Eric Leblond
@ 2014-12-01 11:55 ` Pablo Neira Ayuso
0 siblings, 0 replies; 4+ messages in thread
From: Pablo Neira Ayuso @ 2014-12-01 11:55 UTC (permalink / raw)
To: Eric Leblond; +Cc: netfilter-devel, kaber
On Sat, Nov 29, 2014 at 05:24:38PM +0100, Eric Leblond wrote:
> Current code is causing a failure in adding a set containing
> a really long list of elements. The failure occurs as soon as
> the line is longer than flex read buffer.
>
> When a line is longer than scanner buffer size, the code in YY_INPUT
> forces a rewind to the beginning of the string because it does not
> find a end of line. The result is that the string is never parsed.
>
> This patch updates the code by rewinding till we found a space.
But the part that didn't fit in will be ignore, right? So the user
will lose some elements in the set?
If so, I think it's better to spot an error via YY_FATAL_ERROR to
indicate that the line is too long to the user.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [nft PATCH] scanner: fix reading of really long line
@ 2014-12-01 13:46 Eric Leblond
2014-12-03 11:53 ` Pablo Neira Ayuso
0 siblings, 1 reply; 4+ messages in thread
From: Eric Leblond @ 2014-12-01 13:46 UTC (permalink / raw)
To: Pablo Neira Ayuso; +Cc: Netfilter Devel, Patrick McHardy
Hello,
Le 1 déc. 2014 12:55, Pablo Neira Ayuso <pablo@netfilter.org> a écrit :
>
> On Sat, Nov 29, 2014 at 05:24:38PM +0100, Eric Leblond wrote:
> > Current code is causing a failure in adding a set containing
> > a really long list of elements. The failure occurs as soon as
> > the line is longer than flex read buffer.
> >
> > When a line is longer than scanner buffer size, the code in YY_INPUT
> > forces a rewind to the beginning of the string because it does not
> > find a end of line. The result is that the string is never parsed.
> >
> > This patch updates the code by rewinding till we found a space.
>
> But the part that didn't fit in will be ignore, right? So the user
> will lose some elements in the set?
This is not the case as there is a fseek below to rewind at the correct position. So next read get the data from the correct point.
BR,
> If so, I think it's better to spot an error via YY_FATAL_ERROR to
> indicate that the line is too long to the user.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [nft PATCH] scanner: fix reading of really long line
2014-12-01 13:46 [nft PATCH] scanner: fix reading of really long line Eric Leblond
@ 2014-12-03 11:53 ` Pablo Neira Ayuso
0 siblings, 0 replies; 4+ messages in thread
From: Pablo Neira Ayuso @ 2014-12-03 11:53 UTC (permalink / raw)
To: Eric Leblond; +Cc: Netfilter Devel, Patrick McHardy
On Mon, Dec 01, 2014 at 02:46:04PM +0100, Eric Leblond wrote:
> Hello,
> Le 1 déc. 2014 12:55, Pablo Neira Ayuso <pablo@netfilter.org> a écrit :
> >
> > On Sat, Nov 29, 2014 at 05:24:38PM +0100, Eric Leblond wrote:
> > > Current code is causing a failure in adding a set containing
> > > a really long list of elements. The failure occurs as soon as
> > > the line is longer than flex read buffer.
> > >
> > > When a line is longer than scanner buffer size, the code in YY_INPUT
> > > forces a rewind to the beginning of the string because it does not
> > > find a end of line. The result is that the string is never parsed.
> > >
> > > This patch updates the code by rewinding till we found a space.
> >
> > But the part that didn't fit in will be ignore, right? So the user
> > will lose some elements in the set?
>
> This is not the case as there is a fseek below to rewind at the correct position. So next read get the data from the correct point.
OK. Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-12-03 11:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-01 13:46 [nft PATCH] scanner: fix reading of really long line Eric Leblond
2014-12-03 11:53 ` Pablo Neira Ayuso
-- strict thread matches above, loose matches on Subject: below --
2014-11-29 16:24 Eric Leblond
2014-12-01 11:55 ` Pablo Neira Ayuso
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).