ip/iplink: fix off-by-one KIND length in modify()

The expected size for IFLA_INFO_KIND in kernel is strlen(kind) + 1.
See `size` in rtnl_link_get_size() in net/core/rtnetlink.c.

Fixes: 1d93483985f0 ("iplink: use netlink for link configuration")
Reported-by: Gris Ge <fge@redhat.com>
Signed-off-by: Jan Vaclav <jvaclav@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
This commit is contained in:
Jan Vaclav 2026-01-13 12:41:27 +01:00 committed by Stephen Hemminger
parent fc716da639
commit 683815ed61

View File

@ -1139,7 +1139,7 @@ static int iplink_modify(int cmd, unsigned int flags, int argc, char **argv)
linkinfo = addattr_nest(&req.n, sizeof(req), IFLA_LINKINFO);
addattr_l(&req.n, sizeof(req), IFLA_INFO_KIND, type,
strlen(type));
strlen(type) + 1);
lu = get_link_kind(type);
if (ulinep && !strcmp(ulinep, "_slave"))