]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
cli: Drop String termination workaround
authorPhil Sutter <phil@nwl.cc>
Wed, 11 Apr 2018 08:21:35 +0000 (10:21 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 11 Apr 2018 08:23:02 +0000 (10:23 +0200)
This spot was missed by commit 2b3f18e0cf7a7 ("libnftables: Fix for
input without trailing newline") - since line termination is now added
in nft_run_cmd_from_buffer(), cli is relieved from doing so.

Fixes: 2b3f18e0cf7a7 ("libnftables: Fix for input without trailing newline")
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/cli.c

index eb60d01dad3dcdf5ea6f2388d24dfbdc2ce49477..241ea0105512fa508cb7fec5206b2db02fa8c31f 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -83,8 +83,6 @@ static void cli_complete(char *line)
        const HIST_ENTRY *hist;
        const char *c;
        LIST_HEAD(msgs);
-       int len;
-       char *s;
 
        if (line == NULL) {
                printf("\n");
@@ -112,13 +110,7 @@ static void cli_complete(char *line)
        if (hist == NULL || strcmp(hist->line, line))
                add_history(line);
 
-       len = strlen(line);
-       s = xmalloc(len + 2);
-       snprintf(s, len + 2, "%s\n", line);
-       xfree(line);
-       line = s;
-
-       nft_run_cmd_from_buffer(cli_nft, line, len + 2);
+       nft_run_cmd_from_buffer(cli_nft, line, strlen(line) + 1);
        xfree(line);
 }