From f5392c365447706f772559942ddd6dc9e1d21a07 Mon Sep 17 00:00:00 2001 From: Leo Ruan Date: Sat, 4 Aug 2018 20:07:40 +0200 Subject: [PATCH] Fix parse_rtattr() does not completely initialize Because max is the index of the last element in array tb, max+1 elements need to be initialized. Signed-off-by: Leo Ruan Signed-off-by: Mark Jonas Signed-off-by: Marc Kleine-Budde --- src/libsocketcan.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/libsocketcan.c b/src/libsocketcan.c index c97a28c..093b64a 100644 --- a/src/libsocketcan.c +++ b/src/libsocketcan.c @@ -74,10 +74,18 @@ struct req_info { struct can_bittiming *bittiming; }; +/** + * @brief this method parse attributions of link info + * + * @param tb: point array of struct rtattr point + * @param max: index of the last element in array tb + * @param rtattr: point of link info data + * @param len: length of link info data + */ static void parse_rtattr(struct rtattr **tb, int max, struct rtattr *rta, int len) { - memset(tb, 0, sizeof(*tb) * max); + memset(tb, 0, sizeof(*tb) * (max + 1)); while (RTA_OK(rta, len)) { if (rta->rta_type <= max) { tb[rta->rta_type] = rta;