[PATCH 2/3] attr: prevent garbage return value for NULL param

Peter Wu peter at lekensteyn.nl
Tue Jun 24 14:13:37 PDT 2014


If nla is not given, then tmp is not set. Explicitly initalize with 0
to prevent garbage values. Found by Clang static analyzer.

Signed-off-by: Peter Wu <peter at lekensteyn.nl>
---
 lib/attr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/attr.c b/lib/attr.c
index 66c029c..d3de399 100644
--- a/lib/attr.c
+++ b/lib/attr.c
@@ -648,7 +648,7 @@ int nla_put_u64(struct nl_msg *msg, int attrtype, uint64_t value)
  */
 uint64_t nla_get_u64(struct nlattr *nla)
 {
-	uint64_t tmp;
+	uint64_t tmp = 0;
 
 	nla_memcpy(&tmp, nla, sizeof(tmp));
 
-- 
2.0.0




More information about the libnl mailing list