diff mbox

[opensm] osm_helper.c: Fix out-of-bounds read

Message ID 52162611.7050903@dev.mellanox.co.il (mailing list archive)
State Accepted
Delegated to: Hal Rosenstock
Headers show

Commit Message

Hal Rosenstock Aug. 22, 2013, 2:54 p.m. UTC
From: Dan Ben Yosef <danby@dev.mellanox.co.il>

Overrunning static array "disp_msg_str", with 35 elements, at position
35 with index variable "msg".

Signed-off-by: Dan Ben Yosef <danby@dev.mellanox.co.il>
Signed-off-by: Alex Netes <alexne@mellanox.com>
Signed-off-by: Hal Rosenstock <hal@mellanox.com>
---
 opensm/osm_helper.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/opensm/osm_helper.c b/opensm/osm_helper.c
index d31d088..55f0637 100644
--- a/opensm/osm_helper.c
+++ b/opensm/osm_helper.c
@@ -2941,8 +2941,8 @@  static const char *disp_msg_str[] = {
 
 const char *osm_get_disp_msg_str(IN cl_disp_msgid_t msg)
 {
-	if (msg > OSM_MSG_MAX)
-		msg = OSM_MSG_MAX;
+	if (msg >= OSM_MSG_MAX)
+		msg = OSM_MSG_MAX-1;
 	return disp_msg_str[msg];
 }