From 69e43dc87f13ff9636ef278d644a78e6099bcef8 Mon Sep 17 00:00:00 2001 From: Zdenek Styblik Date: Tue, 12 Feb 2013 12:01:32 +0000 Subject: [PATCH] ID: 3600927 - change eval order of input param in ipmi_oem_setup() Commit changes evaluation order of 'oemtype' which is an input parameter to ipmi_oem_setup() in 'lib/ipmi_oem.c'. Make the check whether 'oemtype' is NULL or not one of the first things we do rather than blindly use 'oemtype' in strncmp() and then check if it isn't NULL. Yes, this is a potential crash waiting to happen. Reported-by: Ales Ledvinka --- ipmitool/lib/ipmi_oem.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ipmitool/lib/ipmi_oem.c b/ipmitool/lib/ipmi_oem.c index 39b2127..de4a1a9 100644 --- a/ipmitool/lib/ipmi_oem.c +++ b/ipmitool/lib/ipmi_oem.c @@ -112,9 +112,9 @@ ipmi_oem_setup(struct ipmi_intf * intf, char * oemtype) struct ipmi_oem_handle * oem; int rc = 0; - if (strncmp(oemtype, "help", 4) == 0 || - strncmp(oemtype, "list", 4) == 0 || - oemtype == NULL) { + if (oemtype == NULL || + strncmp(oemtype, "help", 4) == 0 || + strncmp(oemtype, "list", 4) == 0) { ipmi_oem_print(); return -1; }