This is an automated email from Gerrit.

Antonio Borneo ([email protected]) just uploaded a new patch set to 
Gerrit, which you can find at http://openocd.zylin.com/5242

-- gerrit

commit 7669853f4bd1d9de323d758b6b4a5cf9e25fa45b
Author: Antonio Borneo <[email protected]>
Date:   Wed Jun 19 07:17:27 2019 +0200

    mflash: fix build with gcc 9.1.0
    
    With new gcc we get compile time error:
        In function ‘mg_gen_ataid’,
            inlined from ‘mg_storage_config’ at src/flash/mflash.c:1174:2:
        src/flash/mflash.c:1162:2: error: ‘memset’ offset [509, 512] from the
         object at ‘buff’ is out of the bounds of referenced subobject
         ‘reserved7’ with type ‘mg_io_uint8[186]’ {aka ‘unsigned char[186]’}
         at offset 322 [-Werror=array-bounds]
        1162 |  memset(pSegIdDrvInfo->reserved7, 0x00, 190);
    
    Since its first submission in 2009, mflash code has this field
        mg_io_uint8 reserved7[186];
    that is memset for 190 bytes, clearly overflowing.
    The 4 bytes after reserved7[] in the struct belong to fields that
    are not used, so the overflow is not damaging anything.
    
    Reduce the memset parameter to stay within the array size.
    
    Change-Id: I6f637cc800d61d4365575be07b7f50e73bdd0ca5
    Signed-off-by: Antonio Borneo <[email protected]>

diff --git a/src/flash/mflash.c b/src/flash/mflash.c
index acf1441..36c75d5 100644
--- a/src/flash/mflash.c
+++ b/src/flash/mflash.c
@@ -1159,7 +1159,7 @@ static void mg_gen_ataid(mg_io_type_drv_info 
*pSegIdDrvInfo)
        memset(pSegIdDrvInfo->vendor_uniq_bytes, 0x00, 62);
        /* CFA power mode 1 support in maximum 200mA */
        pSegIdDrvInfo->cfa_pwr_mode                     = 0x0100;
-       memset(pSegIdDrvInfo->reserved7, 0x00, 190);
+       memset(pSegIdDrvInfo->reserved7, 0x00, 186);
 }
 
 static int mg_storage_config(void)

-- 


_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to