diff options
author | Phil Sutter <phil@nwl.cc> | 2019-09-18 15:39:44 +0200 |
---|---|---|
committer | Phil Sutter <phil@nwl.cc> | 2019-11-06 13:41:56 +0100 |
commit | 92991bbe12d77c6129b3a71b25c36fad6a27d75a (patch) | |
tree | b5e18f4a7f468d70ac0ad98a34fc719cacaf67a9 /iptables/xtables-restore.c | |
parent | f308f944a0c1356fbfa2790d12820e9ab1fa8c54 (diff) |
xtables-restore: Allow lines without trailing newline character
Old code in add_param_to_argv() assumed the input line would always end
with a newline character. Without it, the last word of input wasn't
recognized. Fix this by adding a final check for param.len (indicating
leftover data in buffer).
In line parsing code itself, only COMMIT line check required presence of
trailing newline. The replaced conditional is not 100% accurate as it
allows for characters after newline to be present, but since fgets() is
used this shouldn't happen anyway.
Signed-off-by: Phil Sutter <phil@nwl.cc>
Acked-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'iptables/xtables-restore.c')
-rw-r--r-- | iptables/xtables-restore.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/iptables/xtables-restore.c b/iptables/xtables-restore.c index 83e05102..5a534ca2 100644 --- a/iptables/xtables-restore.c +++ b/iptables/xtables-restore.c @@ -88,7 +88,9 @@ static void xtables_restore_parse_line(struct nft_handle *h, if (verbose) fputs(buffer, stdout); return; - } else if ((strcmp(buffer, "COMMIT\n") == 0) && state->in_table) { + } else if (state->in_table && + (strncmp(buffer, "COMMIT", 6) == 0) && + (buffer[6] == '\0' || buffer[6] == '\n')) { if (!p->testing) { /* Commit per table, although we support * global commit at once, stick by now to |