]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
scanner: fix reading of really long line
authorEric Leblond <eric@regit.org>
Sat, 29 Nov 2014 16:24:38 +0000 (17:24 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 1 Dec 2014 16:27:51 +0000 (17:27 +0100)
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>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/scanner.l

index f0ed8d4e253d99f26b45a3a26018350764240d97..2fafa71ae84f84c7779d813920c788ecd9be91c9 100644 (file)
@@ -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);                                      \