diff mbox

[opensm] osm_ucast_file.c: Fix crash when port is invalid in LFT file

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

Commit Message

Hal Rosenstock Dec. 26, 2013, 1:39 p.m. UTC
From: Vladimir Koushnir <vladimirk@mellanox.com>

Signed-off-by: Vladimir Koushnir <vladimirk@mellanox.com>
Signed-off-by: Hal Rosenstock <hal@mellanox.com>
---
 opensm/osm_ucast_file.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
diff mbox

Patch

diff --git a/opensm/osm_ucast_file.c b/opensm/osm_ucast_file.c
index 2c2bf0c..a5408af 100644
--- a/opensm/osm_ucast_file.c
+++ b/opensm/osm_ucast_file.c
@@ -216,6 +216,17 @@  static int do_ucast_file_load(void *context)
 					file_name, lineno, p);
 				goto Exit;
 			}
+			if (port_num >=
+				osm_node_get_num_physp(p_sw->p_node)) {
+					OSM_LOG(&p_osm->log, OSM_LOG_ERROR,
+						"Invalid port %d found "
+						"for switch %016" PRIx64 "\n",
+						port_num,
+						cl_ntoh64(osm_node_get_node_guid
+							(p_sw->p_node)));
+					goto Exit;
+			}
+
 			p = q;
 			/* additionally try to extract guid */
 			q = strstr(p, " portguid 0x");