summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhil Sutter <psutter@redhat.com>2016-08-12 14:39:50 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2016-08-12 15:36:04 +0200
commit9afae310b019aa497afb94833afc9a936bc38a1f (patch)
tree1ccb71e2d6749fd8f3e32b1838de2860dd1feb61
parent1be3625e465d257e913a4cbb2b4329044a322e78 (diff)
utils: Don't return directly from SNPRINTF_BUFFER_SIZE
Apart from being a bad idea in general, the return statement contained in that macro in some cases leads to returning from functions without properly cleaning up, thereby causing memory leaks. Instead, just sanitize the value in 'ret' to not harm further calls of snprintf() (as 'len' will eventually just become zero). Cc: Arturo Borrero <arturo.borrero.glez@gmail.com> Signed-off-by: Phil Sutter <phil@nwl.cc> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r--include/utils.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/include/utils.h b/include/utils.h
index 21694b6..924df32 100644
--- a/include/utils.h
+++ b/include/utils.h
@@ -54,7 +54,7 @@ void __nftnl_assert_attr_exists(uint16_t attr, uint16_t attr_max,
#define SNPRINTF_BUFFER_SIZE(ret, size, len, offset) \
if (ret < 0) \
- return ret; \
+ ret = 0; \
offset += ret; \
if (ret > len) \
ret = len; \