linma / rpms / iproute

Forked from rpms/iproute 4 years ago
Clone

Blame SOURCES/0092-iplink_can-Prevent-overstepping-array-bounds.patch

99be8f
From 4c775c035e2751b1aec52dcc2ca0e4fc99bac793 Mon Sep 17 00:00:00 2001
99be8f
From: Andrea Claudi <aclaudi@redhat.com>
99be8f
Date: Mon, 29 Apr 2019 20:08:07 +0200
99be8f
Subject: [PATCH] iplink_can: Prevent overstepping array bounds
99be8f
99be8f
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1465646
99be8f
Upstream Status: iproute2.git commit 258b7c0fa70c2
99be8f
99be8f
commit 258b7c0fa70c2d6b5f9776cc35c38c80b4ee5752
99be8f
Author: Phil Sutter <phil@nwl.cc>
99be8f
Date:   Mon Aug 21 11:27:00 2017 +0200
99be8f
99be8f
    iplink_can: Prevent overstepping array bounds
99be8f
99be8f
    can_state_names array contains at most CAN_STATE_MAX fields, so allowing
99be8f
    an index to it to be equal to that number is wrong. While here, also
99be8f
    make sure the array is indeed that big so nothing bad happens if
99be8f
    CAN_STATE_MAX ever increases.
99be8f
99be8f
    Signed-off-by: Phil Sutter <phil@nwl.cc>
99be8f
---
99be8f
 ip/iplink_can.c | 4 ++--
99be8f
 1 file changed, 2 insertions(+), 2 deletions(-)
99be8f
99be8f
diff --git a/ip/iplink_can.c b/ip/iplink_can.c
99be8f
index 20d4d37d0d087..4133a658a059e 100644
99be8f
--- a/ip/iplink_can.c
99be8f
+++ b/ip/iplink_can.c
99be8f
@@ -241,7 +241,7 @@ static int can_parse_opt(struct link_util *lu, int argc, char **argv,
99be8f
 	return 0;
99be8f
 }
99be8f
 
99be8f
-static const char *can_state_names[] = {
99be8f
+static const char *can_state_names[CAN_STATE_MAX] = {
99be8f
 	[CAN_STATE_ERROR_ACTIVE] = "ERROR-ACTIVE",
99be8f
 	[CAN_STATE_ERROR_WARNING] = "ERROR-WARNING",
99be8f
 	[CAN_STATE_ERROR_PASSIVE] = "ERROR-PASSIVE",
99be8f
@@ -265,7 +265,7 @@ static void can_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
99be8f
 	if (tb[IFLA_CAN_STATE]) {
99be8f
 		uint32_t state = rta_getattr_u32(tb[IFLA_CAN_STATE]);
99be8f
 
99be8f
-		fprintf(f, "state %s ", state <= CAN_STATE_MAX ?
99be8f
+		fprintf(f, "state %s ", state < CAN_STATE_MAX ?
99be8f
 			can_state_names[state] : "UNKNOWN");
99be8f
 	}
99be8f
 
99be8f
-- 
d30c09
2.21.0
99be8f