[PATCH 1/4] Fix parse_rtattr() does not completely initialize

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux