]> granicus.if.org Git - libnl/commitdiff
addr: Reset unused portion of binary address in nl_addr_set_binary_addr()
authorThomas Graf <tgraf@suug.ch>
Thu, 14 Mar 2013 13:41:12 +0000 (14:41 +0100)
committerThomas Graf <tgraf@suug.ch>
Thu, 14 Mar 2013 13:41:12 +0000 (14:41 +0100)
memset() the binary address before overwriting it with new data
to avoid leaving around old portions of the address.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
lib/addr.c

index 9089be8933e3b316ab51f7bdc419317913ef70da..e75ef70d6cc3eaaa56d9d32491650a38be968d6a 100644 (file)
@@ -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;
 }