Skip to contentSkip to conversation

genl: Handle empty data in l_genl_msg_append_attr

PATCH Applied Andrew Zaborowski 2 participants 2 messages Jan 15, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 genl: Handle empty data in l_genl_msg_append_attr

Make sure l_genl_msg_append_attr can be called with a NULL @data (when @len is 0) for attributes like nl80211 flags, without triggering an asan warning about the memcpy parameter being NULL.

---
 ell/genl.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
ell/genl.c +3 -1
index 32f54bc..2905a5e 100644
@@ -790,7 +790,9 @@ LIB_EXPORT bool l_genl_msg_append_attr(struct l_genl_msg *msg, uint16_t type,
 	nla->nla_len = NLA_HDRLEN + len;
 	nla->nla_type = type;
 
-	memcpy(msg->data + msg->len + NLA_HDRLEN, data, len);
+	if (len)
+		memcpy(msg->data + msg->len + NLA_HDRLEN, data, len);
+
 	msg->len += NLA_HDRLEN + NLA_ALIGN(len);
 
 	return true;
Signature · 1 line
2.19.1
#1 lore raw

Hi Andrew,

Quoted 6 lines · Andrew Zaborowski

Make sure l_genl_msg_append_attr can be called with a NULL @data (when @len is 0) for attributes like nl80211 flags, without triggering an asan warning about the memcpy parameter being NULL.

---
  ell/genl.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)

Applied, thanks.

Regards,
-Denis