From: Leo Ruan <tingquan.ruan@xxxxxxxxxxxx> Because max is the index of the last element in array tb, max+1 elements need to be initialized. Signed-off-by: Leo Ruan <tingquan.ruan@xxxxxxxxxxxx> Signed-off-by: Mark Jonas <mark.jonas@xxxxxxxxxxxx> --- src/libsocketcan.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/libsocketcan.c b/src/libsocketcan.c index c97a28c..95409dd 100644 --- a/src/libsocketcan.c +++ b/src/libsocketcan.c @@ -74,10 +74,17 @@ 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; -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-can" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html