Skip to content

Commit

Permalink
net/tap: avoid memcpy with null argument
Browse files Browse the repository at this point in the history
Calling memcpy with a null pointer even if zero length is
undefined, so check if data_length is zero.
Problem reported by Gcc analyzer.

Fixes: 7c25284 ("net/tap: add netlink back-end for flow API")
Cc: stable@dpdk.org

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
  • Loading branch information
shemminger authored and ferruhy committed Aug 19, 2024
1 parent e0f7ebe commit e3f198f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/net/tap/tap_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,8 @@ tap_nlattr_add(struct nlmsghdr *nh, unsigned short type,
rta = (struct rtattr *)NLMSG_TAIL(nh);
rta->rta_len = RTA_LENGTH(data_len);
rta->rta_type = type;
memcpy(RTA_DATA(rta), data, data_len);
if (data_len > 0)
memcpy(RTA_DATA(rta), data, data_len);
nh->nlmsg_len = NLMSG_ALIGN(nh->nlmsg_len) + RTA_ALIGN(rta->rta_len);
}

Expand Down

0 comments on commit e3f198f

Please sign in to comment.