[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH] 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 <mukesh.rathor@xxxxxxxxxx>

diff -r 0705efd9c69e -r 231c46fef5c5 tools/debugger/gdbsx/gx/gx_comm.c
--- a/tools/debugger/gdbsx/gx/gx_comm.c Fri Oct 16 09:04:53 2009 +0100
+++ b/tools/debugger/gdbsx/gx/gx_comm.c Fri Oct 16 16:21:00 2009 -0700
@@ -299,6 +299,7 @@
 
         if (write(remote_fd, buf2, p - buf2) != p - buf2) {
             perror("putpkt(write)");
+            free(buf2);
             return -1;
         }
         if (gx_remote_dbg)
diff -r 0705efd9c69e -r 231c46fef5c5 tools/debugger/gdbsx/gx/gx_main.c
--- a/tools/debugger/gdbsx/gx/gx_main.c Fri Oct 16 09:04:53 2009 +0100
+++ b/tools/debugger/gdbsx/gx/gx_main.c Fri Oct 16 16:21:00 2009 -0700
@@ -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;
     }

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.