[PATCH phosphor-host-ipmid] Fix a buffer overrun

OpenBMC Patches patches at stwcx.xyz
Tue Oct 20 15:04:18 AEDT 2015


From: Chris Austen <austenc at us.ibm.com>

---
 ipmisensor.C | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/ipmisensor.C b/ipmisensor.C
index f60db18..568f4a4 100644
--- a/ipmisensor.C
+++ b/ipmisensor.C
@@ -98,16 +98,16 @@ char *getfw02string(uint8_t b) {
 //  prior to calling the dbus code.  
 int set_sensor_dbus_state_fwprogress(const sensorRES_t *pRec, const lookup_t *pTable, const char *value) {
 
-	char valuestring[32];
+	char valuestring[48];
 	char* pStr = valuestring;
 
 	switch (pTable->offset) {
 
-		case 0x00 : sprintf(valuestring, "POST Error, 0x%02x", pRec->event_data2);
+		case 0x00 : snprintf(valuestring, sizeof(valuestring), "POST Error, 0x%02x", pRec->event_data2);
 					break;
-		case 0x01 : sprintf(valuestring, "FW Hang, 0x%02x", pRec->event_data2);
+		case 0x01 : snprintf(valuestring, sizeof(valuestring), "FW Hang, 0x%02x", pRec->event_data2);
 					break;
-		case 0x02 : sprintf(valuestring, "FW Progress, %s", getfw02string(pRec->event_data2));
+		case 0x02 : snprintf(valuestring, sizeof(valuestring), "FW Progress, %s", getfw02string(pRec->event_data2));
 	}
 
 	return set_sensor_dbus_state_v(pRec->sensor_number, pTable->method, pStr);
-- 
2.6.0




More information about the openbmc mailing list