From fa21266ec293db84b2eba7120d3f2d4211d96499 Mon Sep 17 00:00:00 2001 From: Duncan Laurie Date: Fri, 28 Jul 2006 16:39:18 +0000 Subject: [PATCH] fix segfault when incorrect oem option supplied --- ipmitool/lib/ipmi_oem.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/ipmitool/lib/ipmi_oem.c b/ipmitool/lib/ipmi_oem.c index 3ba387c..39b2127 100644 --- a/ipmitool/lib/ipmi_oem.c +++ b/ipmitool/lib/ipmi_oem.c @@ -63,7 +63,7 @@ static struct ipmi_oem_handle ipmi_oem_list[] = { desc: "IBM OEM support", setup: ipmi_oem_ibm, }, - { 0 }, + { 0 } }; /* Supermicro IPMIv2 BMCs use OEM authtype */ @@ -110,7 +110,6 @@ int ipmi_oem_setup(struct ipmi_intf * intf, char * oemtype) { struct ipmi_oem_handle * oem; - int i; int rc = 0; if (strncmp(oemtype, "help", 4) == 0 || @@ -120,18 +119,13 @@ ipmi_oem_setup(struct ipmi_intf * intf, char * oemtype) return -1; } - for (oem=ipmi_oem_list, i=0; i < sizeof(ipmi_oem_list)/sizeof(struct ipmi_oem_handle); oem++, i++) { - if (oem->name == NULL) - continue; + for (oem=ipmi_oem_list; oem->name != NULL; oem++) { if (strncmp(oemtype, oem->name, strlen(oem->name)) == 0) break; } - if (oem->name == NULL) { - /* nothing was found */ - lprintf(LOG_ERR, "OEM support not found for \"%s\"", oemtype); + if (oem->name == NULL) return -1; - } /* save pointer for later use */ intf->oem = oem; @@ -164,4 +158,3 @@ ipmi_oem_active(struct ipmi_intf * intf, const char * oemtype) return 0; } -