gdbsx: malloc extra bye for null char
PATCH 1/1 gdbsx: malloc extra bye for null char
Well, that didn't take long for someone to break gdbsx :). Attached and included is a fix to allocate extra byte for null char.
thanks
mukesh
# HG changeset patch
# User Mukesh Rathor
# Date 1255735260 25200
# Node ID 231c46fef5c5efc177cf18606a7e99c6591cba35 # Parent 0705efd9c69e2e254c85bc4381166b7f9cfb8ee3 malloc extra bye for null char.
Signed-off-by Mukesh Rathor <[email protected]>
tools/debugger/gdbsx/gx/gx_comm.c +1 -0
@@ -299,6 +299,7 @@if (write (remote_fd, buf2, p - buf2) != p - buf2) {perror ("putpkt(write)" ); +free (buf2);return -1 ; }if (gx_remote_dbg)
tools/debugger/gdbsx/gx/gx_main.c +2 -2
@@ -201,7 +201,7 @@gx_decode_m_packet (&remote_buf[1 ], &addr, &len); -if ((xbuf=malloc (len)) ==NULL ) { +if ((xbuf=malloc (len+1 )) ==NULL ) {gx_reply_error (remote_buf);return ; }
@@ -227,7 +227,7 @@ data_strtp =gx_decode_M_packet (&remote_buf[1 ], &addr, &len); -if ((xbuf=malloc (len)) ==NULL ) { +if ((xbuf=malloc (len+1 )) ==NULL ) {gx_reply_error (remote_buf);return ; }