From aabd9eb1ac0153c245f4f94cf008afbf7d195dc2 Mon Sep 17 00:00:00 2001 From: Zdenek Styblik Date: Thu, 22 Jan 2015 06:20:55 +0100 Subject: [PATCH] ID:355 - Fix zero-length format string warning in get_supermicro_evt_desc() --- lib/ipmi_sel.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/ipmi_sel.c b/lib/ipmi_sel.c index 163b5e9..99b22b5 100644 --- a/lib/ipmi_sel.c +++ b/lib/ipmi_sel.c @@ -556,12 +556,12 @@ get_supermicro_evt_desc(struct ipmi_intf *intf, struct sel_event_record *rec) return NULL; } /* Allocate mem for te Description string */ - desc = (char *)malloc(SIZE_OF_DESC); + desc = malloc(sizeof(char) * SIZE_OF_DESC); if (desc == NULL) { lprintf(LOG_ERR, "ipmitool: malloc failure"); return NULL; } - memset(desc,0,SIZE_OF_DESC); + memset(desc, '\0', SIZE_OF_DESC); sensor_type = rec->sel_type.standard_type.sensor_type; switch (sensor_type) { case SENSOR_TYPE_MEMORY: @@ -623,7 +623,8 @@ get_supermicro_evt_desc(struct ipmi_intf *intf, struct sel_event_record *rec) (data2 >> 4) + 0x40 + (data3 & 0x3) * 3, (data2 & 0xf) + 0x27, (data3 & 0x03) + 1); } else { - snprintf(desc, SIZE_OF_DESC, ""); + /* No description. */ + desc[0] = '\0'; } break; case SENSOR_TYPE_SUPERMICRO_OEM: