Skip to contentSkip to conversation

opensm/osm_helper.c: fix potential overrun of the array

PATCH Applied Yevgeny Kliteynik 3 participants 4 messages Sep 7, 2010 – Sep 12, 2010 1 message not in the archive InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 opensm/osm_helper.c: fix potential overrun of the array

Max index of the ib_sm_method_str[] static array
is 0x20. Fixing OSM_SM_METHOD_STR_UNKNOWN_VAL to
match this value.

---
 opensm/opensm/osm_helper.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
opensm/opensm/osm_helper.c +1 -1
index 196d5aa..0233e70 100644
@@ -148,7 +148,7 @@ static const char *ib_sm_method_str[] = {
 	"UNKNOWN"		/* 20 */
 };
 
-#define OSM_SM_METHOD_STR_UNKNOWN_VAL 0x21
+#define OSM_SM_METHOD_STR_UNKNOWN_VAL 0x20
 
 static const char *ib_sm_attr_str[] = {
 	"RESERVED",		/* 0 */
Signature · 6 lines
1.6.2.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 4C865419.9050005-VPRAkNaXOzVS1MOuV/[email protected]

#3 lore raw
In reply to a message not in the archive
Quoted 14 lines · Yevgeny Kliteynik

Max index of the ib_sm_method_str[] static array
is 0x20. Fixing OSM_SM_METHOD_STR_UNKNOWN_VAL to
match this value.

---
 opensm/opensm/osm_helper.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
opensm/opensm/osm_helper.c +0 -0
index 196d5aa..0233e70 100644

opensm/opensm/osm_helper.c static const char *ib_sm_method_str[] = { · line 151

Quoted 5 lines
opensm/opensm/osm_helper.c +1 -1
@@ -148,7 +148,7 @@ static const char *ib_sm_method_str[] = {
 	"UNKNOWN"		/* 20 */
 };
 
-#define OSM_SM_METHOD_STR_UNKNOWN_VAL 0x21
+#define OSM_SM_METHOD_STR_UNKNOWN_VAL 0x20

BTW, wouldn't it be better to use ARR_SIZE macro for those defines:

#define OSM_SM_METHOD_STR_UNKNOWN_VAL ARR_SIZE(ib_sm_method_str)

, where:

#define ARR_SIZE(a) (sizeof(a)/sizeof(a[0]))

?

Sasha

Quoted 6 lines
opensm/opensm/osm_helper.c +0 -0
 static const char *ib_sm_attr_str[] = {
 	"RESERVED",		/* 0 */
Signature · 1 line
1.6.2.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw
Quoted 18 lines · Sasha Khapyorsky
Quoted 17 lines · Yevgeny Kliteynik

Max index of the ib_sm_method_str[] static array
is 0x20. Fixing OSM_SM_METHOD_STR_UNKNOWN_VAL to
match this value.

---
  opensm/opensm/osm_helper.c |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
opensm/opensm/osm_helper.c +0 -0
index 196d5aa..0233e70 100644
@@ -148,7 +148,7 @@ static const char *ib_sm_method_str[] = {
  	"UNKNOWN"		/* 20 */
  };
 
Quoted 6 lines

opensm/opensm/osm_helper.c static const char *ib_sm_method_str[] = { · line 151

Quoted 2 lines
opensm/opensm/osm_helper.c +1 -1
-#define OSM_SM_METHOD_STR_UNKNOWN_VAL 0x21
+#define OSM_SM_METHOD_STR_UNKNOWN_VAL 0x20

BTW, wouldn't it be better to use ARR_SIZE macro for those defines:

#define OSM_SM_METHOD_STR_UNKNOWN_VAL ARR_SIZE(ib_sm_method_str)

Good idea, with a small fix:

#define OSM_SM_METHOD_STR_UNKNOWN_VAL (ARR_SIZE(ib_sm_method_str) - 1)

-- Yevgeny

Quoted 15 lines

, where:

#define ARR_SIZE(a) (sizeof(a)/sizeof(a[0]))

?

Sasha

Quoted 6 lines
opensm/opensm/osm_helper.c +0 -0
  static const char *ib_sm_attr_str[] = {
  	"RESERVED",		/* 0 */
Signature · 1 line
1.6.2.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html