From f0f33c394b97341e824b5fdf62707fcd25ef84cc Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Thu, 14 Mar 2013 14:41:12 +0100 Subject: [PATCH] addr: Reset unused portion of binary address in nl_addr_set_binary_addr() memset() the binary address before overwriting it with new data to avoid leaving around old portions of the address. Signed-off-by: Thomas Graf --- lib/addr.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/addr.c b/lib/addr.c index 9089be8..e75ef70 100644 --- a/lib/addr.c +++ b/lib/addr.c @@ -766,7 +766,10 @@ int nl_addr_set_binary_addr(struct nl_addr *addr, void *buf, size_t len) return -NLE_RANGE; addr->a_len = len; - memcpy(addr->a_addr, buf, len); + memset(addr->a_addr, 0, addr->a_maxsize); + + if (len) + memcpy(addr->a_addr, buf, len); return 0; }