Message ID | 1471005590-18276-1-git-send-email-phil@nwl.cc |
---|---|
State | Accepted |
Delegated to: | Pablo Neira |
Headers | show |
On Fri, Aug 12, 2016 at 02:39:50PM +0200, Phil Sutter wrote: > From: Phil Sutter <psutter@redhat.com> > > 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). Applied, thanks. -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/include/utils.h b/include/utils.h index 21694b6ab1912..924df324aa603 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; \