From ba9a3139119abf59e7a0585a5111c333a6a6c931 Mon Sep 17 00:00:00 2001 From: Zdenek Styblik Date: Thu, 14 Mar 2013 08:38:32 +0000 Subject: [PATCH] ID: 3600926 - 'lib/ipmi_lanp.c' Commit replaces condition ``if (p == NULL)'' in get_lan_param_select(). This condition is never met, because structure is on heap. Condition is replaced by for() control structure which goes through structure ipmi_lan_params and checks whether requested LAN parameter is defined in structure or not. Reported-by: Ales Ledvinka --- ipmitool/lib/ipmi_lanp.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/ipmitool/lib/ipmi_lanp.c b/ipmitool/lib/ipmi_lanp.c index 86e6652..af0daf1 100644 --- a/ipmitool/lib/ipmi_lanp.c +++ b/ipmitool/lib/ipmi_lanp.c @@ -117,14 +117,23 @@ find_lan_channel(struct ipmi_intf * intf, uint8_t start) static struct lan_param * get_lan_param_select(struct ipmi_intf * intf, uint8_t chan, int param, int select) { - struct lan_param * p; + struct lan_param * p = NULL; struct ipmi_rs * rsp; struct ipmi_rq req; + int i = 0; uint8_t msg_data[4]; - p = &ipmi_lan_params[param]; - if (p == NULL) + for (i = 0; ipmi_lan_params[i].cmd != (-1); i++) { + if (ipmi_lan_params[i].cmd == param) { + p = &ipmi_lan_params[param]; + break; + } + } + + if (p == NULL) { + lprintf(LOG_INFO, "Get LAN Parameter failed: Unknown parameter."); return NULL; + } msg_data[0] = chan; msg_data[1] = p->cmd;