summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am1
-rw-r--r--src/cli.c2
-rw-r--r--src/libnftables.c14
-rw-r--r--src/main.c2
-rw-r--r--src/parser_json.c2
5 files changed, 10 insertions, 11 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index a4ad8cb3..92ac61a6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -70,6 +70,7 @@ libparser_la_CFLAGS = ${AM_CFLAGS} \
-Wno-redundant-decls
libnftables_la_LIBADD = ${LIBMNL_LIBS} ${LIBNFTNL_LIBS} libparser.la
+libnftables_la_LDFLAGS = -version-info 1:0:0
if BUILD_MINIGMP
noinst_LTLIBRARIES += libminigmp.la
diff --git a/src/cli.c b/src/cli.c
index 241ea010..ca3869ab 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -110,7 +110,7 @@ static void cli_complete(char *line)
if (hist == NULL || strcmp(hist->line, line))
add_history(line);
- nft_run_cmd_from_buffer(cli_nft, line, strlen(line) + 1);
+ nft_run_cmd_from_buffer(cli_nft, line);
xfree(line);
}
diff --git a/src/libnftables.c b/src/libnftables.c
index dda986ca..9a97a3c5 100644
--- a/src/libnftables.c
+++ b/src/libnftables.c
@@ -396,7 +396,7 @@ static const struct input_descriptor indesc_cmdline = {
.name = "<cmdline>",
};
-static int nft_parse_bison_buffer(struct nft_ctx *nft, char *buf, size_t buflen,
+static int nft_parse_bison_buffer(struct nft_ctx *nft, const char *buf,
struct list_head *msgs, struct list_head *cmds)
{
struct cmd *cmd;
@@ -438,23 +438,21 @@ static int nft_parse_bison_filename(struct nft_ctx *nft, const char *filename,
return 0;
}
-int nft_run_cmd_from_buffer(struct nft_ctx *nft, char *buf, size_t buflen)
+int nft_run_cmd_from_buffer(struct nft_ctx *nft, const char *buf)
{
struct cmd *cmd, *next;
LIST_HEAD(msgs);
LIST_HEAD(cmds);
- size_t nlbuflen;
char *nlbuf;
int rc = -EINVAL;
- nlbuflen = max(buflen + 1, strlen(buf) + 2);
- nlbuf = xzalloc(nlbuflen);
- snprintf(nlbuf, nlbuflen, "%s\n", buf);
+ nlbuf = xzalloc(strlen(buf) + 2);
+ sprintf(nlbuf, "%s\n", buf);
if (nft->output.json)
- rc = nft_parse_json_buffer(nft, nlbuf, nlbuflen, &msgs, &cmds);
+ rc = nft_parse_json_buffer(nft, nlbuf, &msgs, &cmds);
if (rc == -EINVAL)
- rc = nft_parse_bison_buffer(nft, nlbuf, nlbuflen, &msgs, &cmds);
+ rc = nft_parse_bison_buffer(nft, nlbuf, &msgs, &cmds);
if (rc)
goto err;
diff --git a/src/main.c b/src/main.c
index f3615974..b2966a41 100644
--- a/src/main.c
+++ b/src/main.c
@@ -279,7 +279,7 @@ int main(int argc, char * const *argv)
if (i + 1 < argc)
strcat(buf, " ");
}
- rc = !!nft_run_cmd_from_buffer(nft, buf, len);
+ rc = !!nft_run_cmd_from_buffer(nft, buf);
} else if (filename != NULL) {
rc = !!nft_run_cmd_from_filename(nft, filename);
} else if (interactive) {
diff --git a/src/parser_json.c b/src/parser_json.c
index 2fd0ef83..8f29aaf7 100644
--- a/src/parser_json.c
+++ b/src/parser_json.c
@@ -3120,7 +3120,7 @@ static int __json_parse(struct json_ctx *ctx, json_t *root)
}
-int nft_parse_json_buffer(struct nft_ctx *nft, char *buf, size_t buflen,
+int nft_parse_json_buffer(struct nft_ctx *nft, const char *buf,
struct list_head *msgs, struct list_head *cmds)
{
struct json_ctx ctx = {