This is an automated email from Gerrit.

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

-- gerrit

commit 6a3f4921653dad2c9c31e44e2f46d2f2884a8cd5
Author: Andreas Fritiofson <[email protected]>
Date:   Thu Jul 19 00:02:46 2012 +0200

    kinetis: bugfix in kinetis_write() fallback path
    
    Offset calculation into buffer was wrong and code would read outside buffer
    if count was not a multiple of four.
    
    Change-Id: Ied625b10221423d5a5f25d27ce1edd8c2c3eca8a
    Signed-off-by: Andreas Fritiofson <[email protected]>

diff --git a/src/flash/nor/kinetis.c b/src/flash/nor/kinetis.c
index cf36104..65f3472 100644
--- a/src/flash/nor/kinetis.c
+++ b/src/flash/nor/kinetis.c
@@ -392,7 +392,13 @@ static int kinetis_write(struct flash_bank *bank, uint8_t 
*buffer,
                        LOG_DEBUG("write longword @ %08X", offset + i);
 
                        w0 = (0x06 << 24) | (bank->base + offset + i);
-                       w1 = buf_get_u32(buffer + offset + i, 0, 32);
+                       if (count - i < 4) {
+                               uint32_t padding = 0xffffffff;
+                               memcpy(&padding, buffer + i, count - i);
+                               w1 = buf_get_u32(&padding, 0, 32);
+                       } else {
+                               w1 = buf_get_u32(buffer + i, 0, 32);
+                       }
 
                        result = kinetis_ftfx_command(bank, w0, w1, w2, 
&ftfx_fstat);
 

-- 

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to