From 5b90f68407215bc43b3603d407675401bbbd2e06 Mon Sep 17 00:00:00 2001 From: Zdenek Styblik Date: Sun, 11 Nov 2012 18:26:36 +0000 Subject: [PATCH] ID: 3528368 - 'lib/ipmi_sdr.c' - possible int *flow Commit fixes possible int *flow in ipmi_sdr_print_type() in 'lib/ipmi_sdr.c'. str2uchar() is used instead of strtol() which wasn't being checked for errors. Reported by: Duncan Idaho --- ipmitool/lib/ipmi_sdr.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ipmitool/lib/ipmi_sdr.c b/ipmitool/lib/ipmi_sdr.c index 057ed5f..9f97a15 100644 --- a/ipmitool/lib/ipmi_sdr.c +++ b/ipmitool/lib/ipmi_sdr.c @@ -4323,7 +4323,12 @@ ipmi_sdr_print_type(struct ipmi_intf *intf, char *type) if (strncmp(type, "0x", 2) == 0) { /* begins with 0x so let it be entered as raw hex value */ - sensor_type = (uint8_t) strtol(type, NULL, 0); + if (str2uchar(type, &sensor_type) != 1) { + lprintf(LOG_ERR, + "Given type of sensor \"%s\" is either invalid or out of range.", + type); + return (-1); + } } else { for (x = 1; x < SENSOR_TYPE_MAX; x++) { if (strncasecmp(sensor_type_desc[x], type,