This is an automated email from Gerrit.

Christian Eggers (cegg...@gmx.de) just uploaded a new patch set to Gerrit, 
which you can find at http://openocd.zylin.com/1924

-- gerrit

commit 00ee63fc87be2b11bec317ea90c769608ae6ac4e
Author: Christian Eggers <cegg...@gmx.de>
Date:   Mon Feb 3 20:30:32 2014 +0100

    gdb_server: Don't modify "buf" argument in decode_xfer_read()
    
    Make a temporary copy of argument "buf" before modifying it.
    This change is necessary in order to make packet[] "const".
    
    Change-Id: I41eddc2edba1a88384aa7f5591fe50f6ee6a135c
    Signed-off-by: Christian Eggers <cegg...@gmx.de>

diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c
index 2f2d622..619a834 100644
--- a/src/server/gdb_server.c
+++ b/src/server/gdb_server.c
@@ -1659,15 +1659,19 @@ static void xml_printf(int *retval, char **xml, int 
*pos, int *size,
        }
 }
 
-static int decode_xfer_read(char *buf, int *ofs, unsigned int *len)
+static int decode_xfer_read(char *_buf, int *ofs, unsigned int *len)
 {
+       int ret = 0;
+       char *buf = strdup(_buf);
        char *separator;
 
        /* Extract and NUL-terminate the annex. */
        while (*buf && *buf != ':')
                buf++;
-       if (*buf == '\0')
-               return -1;
+       if (*buf == '\0') {
+               ret = -1;
+               goto out;
+       }
        *buf++ = 0;
 
        /* After the read marker and annex, qXfer looks like a
@@ -1675,12 +1679,16 @@ static int decode_xfer_read(char *buf, int *ofs, 
unsigned int *len)
 
        *ofs = strtoul(buf, &separator, 16);
 
-       if (*separator != ',')
-               return -1;
+       if (*separator != ',') {
+               ret = -1;
+               goto out;
+       }
 
        *len = strtoul(separator + 1, NULL, 16);
 
-       return 0;
+out:
+       free(buf);
+       return ret;
 }
 
 static int compare_bank(const void *a, const void *b)

-- 

------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
OpenOCD-devel mailing list
OpenOCD-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to