From 92991bbe12d77c6129b3a71b25c36fad6a27d75a Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Wed, 18 Sep 2019 15:39:44 +0200 Subject: 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 Acked-by: Pablo Neira Ayuso --- iptables/xshared.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'iptables/xshared.c') diff --git a/iptables/xshared.c b/iptables/xshared.c index 2a0077d9..16c58914 100644 --- a/iptables/xshared.c +++ b/iptables/xshared.c @@ -530,6 +530,10 @@ void add_param_to_argv(struct argv_store *store, char *parsestart, int line) param.len = 0; quoted = 0; } + if (param.len) { + param.buffer[param.len] = '\0'; + add_argv(store, param.buffer, 0); + } } #ifdef DEBUG -- cgit v1.2.3