diff options
Diffstat (limited to 'src/chain.c')
-rw-r--r-- | src/chain.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/chain.c b/src/chain.c index d2fafd5..6df871d 100644 --- a/src/chain.c +++ b/src/chain.c @@ -827,6 +827,9 @@ static int nftnl_chain_cmd_snprintf(char *buf, size_t size, { int ret, remain = size, offset = 0; + if (size) + buf[0] = '\0'; + ret = nftnl_cmd_header_snprintf(buf + offset, remain, cmd, type, flags); SNPRINTF_BUFFER_SIZE(ret, remain, offset); @@ -853,14 +856,20 @@ static int nftnl_chain_cmd_snprintf(char *buf, size_t size, int nftnl_chain_snprintf(char *buf, size_t size, const struct nftnl_chain *c, uint32_t type, uint32_t flags) { - return nftnl_chain_cmd_snprintf(buf, size, c, nftnl_flag2cmd(flags), type, - flags); + if (size) + buf[0] = '\0'; + + return nftnl_chain_cmd_snprintf(buf, size, c, nftnl_flag2cmd(flags), + type, flags); } EXPORT_SYMBOL(nftnl_chain_snprintf); static int nftnl_chain_do_snprintf(char *buf, size_t size, const void *c, uint32_t cmd, uint32_t type, uint32_t flags) { + if (size) + buf[0] = '\0'; + return nftnl_chain_snprintf(buf, size, c, type, flags); } |