Initialize the whole array passed to rtnl_rtattr_parse() and don't ignore the last attribute with the maximum value. This will be needed to get the ETHTOOL_A_PHC_VCLOCKS_INDEX attribute.
Signed-off-by: Miroslav Lichvar <mlich...@redhat.com> Acked-by: Hangbin Liu <liuhang...@gmail.com> --- rtnl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rtnl.c b/rtnl.c index fe625d6..f8bdbe6 100644 --- a/rtnl.c +++ b/rtnl.c @@ -178,10 +178,10 @@ static int rtnl_rtattr_parse(struct rtattr *tb[], int max, struct rtattr *rta, i { unsigned short type; - memset(tb, 0, sizeof(struct rtattr *) * max); + memset(tb, 0, sizeof(struct rtattr *) * (max + 1)); while (RTA_OK(rta, len)) { type = rta->rta_type; - if ((type < max) && (!tb[type])) + if ((type <= max) && (!tb[type])) tb[type] = rta; rta = RTA_NEXT(rta, len); } @@ -200,8 +200,8 @@ static inline int rtnl_nested_rtattr_parse(struct rtattr *tb[], int max, struct static int rtnl_linkinfo_parse(int master_index, struct rtattr *rta) { - struct rtattr *linkinfo[IFLA_INFO_MAX]; - struct rtattr *bond[IFLA_BOND_MAX]; + struct rtattr *linkinfo[IFLA_INFO_MAX+1]; + struct rtattr *bond[IFLA_BOND_MAX+1]; int index = -1; char *kind; -- 2.35.1 _______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel