Skip to contentSkip to conversation

opensm: fix strtoull error handling

PATCH Applied Ira Weiny 2 participants 2 messages Apr 15, 2011 – Apr 17, 2011 1 message not in the archive InfiniBand

lore
Share & tools
lore

Ira Weiny

author
#0 lore raw

PATCH 1/1 opensm: fix strtoull error handling

Subject: [PATCH] opensm: fix strtoull error handling

The man page states that errno _may_ be returned when the string can not be converted. Check that the entire string was consumed otherwise assume this is not a guid.

---
 opensm/osm_perfmgr.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
opensm/osm_perfmgr.c +3 -2
index 3e1575a..1cbbb71 100644
@@ -1419,8 +1419,9 @@ void osm_perfmgr_dump_counters(osm_perfmgr_t * pm, perfmgr_db_dump_t dump_type)
  *******************************************************************/
 void osm_perfmgr_print_counters(osm_perfmgr_t * pm, char *nodename, FILE * fp)
 {
-	uint64_t guid = strtoull(nodename, NULL, 0);
-	if (guid == 0 && errno)
+	char *end = NULL;
+	uint64_t guid = strtoull(nodename, &end, 0);
+	if (nodename + strlen(nodename) != end)
 		perfmgr_db_print_by_name(pm->db, nodename, fp);
 	else
 		perfmgr_db_print_by_guid(pm->db, guid, fp);
Signature · 6 lines
1.7.1

--
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
Applied
#2 lore raw
In reply to a message not in the archive
Quoted 8 lines · Ira Weiny

Subject: [PATCH] opensm: fix strtoull error handling

The man page states that errno _may_ be returned when the string can not be converted. Check that the entire string was consumed otherwise assume this is not a guid.

---

Applied, thanks.

-- Alex
--
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