From 72386012200a96f9bb721ab4ddb5a9325c68c5f7 Mon Sep 17 00:00:00 2001 From: Varsha Rao Date: Wed, 20 Sep 2017 21:53:09 +0530 Subject: src: Buffer is null terminated. In _snprintf() functions definition the buffer is null terminated. Signed-off-by: Varsha Rao Signed-off-by: Pablo Neira Ayuso --- src/set.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/set.c') diff --git a/src/set.c b/src/set.c index 25a6fbf..a4e41d2 100644 --- a/src/set.c +++ b/src/set.c @@ -895,6 +895,9 @@ static int nftnl_set_cmd_snprintf(char *buf, size_t size, if (type == NFTNL_OUTPUT_XML) return 0; + if (size) + buf[0] = '\0'; + /* prevent set_elems to print as events */ inner_flags &= ~NFTNL_OF_EVENT_ANY; @@ -925,6 +928,9 @@ static int nftnl_set_cmd_snprintf(char *buf, size_t size, int nftnl_set_snprintf(char *buf, size_t size, const struct nftnl_set *s, uint32_t type, uint32_t flags) { + if (size) + buf[0] = '\0'; + return nftnl_set_cmd_snprintf(buf, size, s, nftnl_flag2cmd(flags), type, flags); } @@ -933,6 +939,9 @@ EXPORT_SYMBOL(nftnl_set_snprintf); static int nftnl_set_do_snprintf(char *buf, size_t size, const void *s, uint32_t cmd, uint32_t type, uint32_t flags) { + if (size) + buf[0] = '\0'; + return nftnl_set_snprintf(buf, size, s, type, flags); } -- cgit v1.2.3