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/common.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/common.c') diff --git a/src/common.c b/src/common.c index a95883c..ba5a49f 100644 --- a/src/common.c +++ b/src/common.c @@ -94,6 +94,9 @@ EXPORT_SYMBOL(nftnl_parse_perror); int nftnl_cmd_header_snprintf(char *buf, size_t size, uint32_t cmd, uint32_t type, uint32_t flags) { + if (size) + buf[0] = '\0'; + NFTNL_BUF_INIT(b, buf, size); if (cmd == NFTNL_CMD_UNSPEC) @@ -135,6 +138,9 @@ int nftnl_cmd_header_fprintf(FILE *fp, uint32_t cmd, uint32_t type, int nftnl_cmd_footer_snprintf(char *buf, size_t size, uint32_t cmd, uint32_t type, uint32_t flags) { + if (size) + buf[0] = '\0'; + NFTNL_BUF_INIT(b, buf, size); if (cmd == NFTNL_CMD_UNSPEC) -- cgit v1.2.3