[Linuxptp-devel] [PATCHv1 1/4] rtnl: Fix rtnl_rtattr_parse() to process max attribute.
PTP IEEE 1588 stack for Linux
Brought to you by:
rcochran
From: Miroslav L. <mli...@re...> - 2022-02-03 11:50:27
|
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 <mli...@re...> Acked-by: Hangbin Liu <liu...@gm...> --- 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.34.1 |