[PATCH phosphor-host-ipmid 6/7] apphandler: Remove out of bounds array access

OpenBMC Patches openbmc-patches at stwcx.xyz
Wed Nov 25 18:10:23 AEDT 2015


From: Joel Stanley <joel at jms.id.au>

apphandler.C:188:24: warning: array subscript is above array bounds [-Warray-bounds]
             tmp_array[3] = '\0';
                        ^

Initalise tmp_array to zero, and avoid this bad access.

Signed-off-by: Joel Stanley <joel at jms.id.au>
---
 apphandler.C | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/apphandler.C b/apphandler.C
index d3df330..2c9ce6b 100644
--- a/apphandler.C
+++ b/apphandler.C
@@ -184,8 +184,7 @@ ipmi_ret_t ipmi_app_get_device_guid(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
 
         for(i = 0; i < tmp_size; i++)
         {
-            char tmp_array[3]; // Holder of the 2 chars that will become a byte
-            tmp_array[3] = '\0';
+            char tmp_array[3] = {0}; // Holder of the 2 chars that will become a byte
             strncpy(tmp_array, id_octet, 2); // 2 chars at a time
 
             int resp_byte = strtoul(tmp_array, NULL, 16); // Convert to hex byte
-- 
2.6.3




More information about the openbmc mailing list