WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] gdbsx: malloc extra bye for null char

To: "Xen-devel@xxxxxxxxxxxxxxxxxxx" <Xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] gdbsx: malloc extra bye for null char
From: Mukesh Rathor <mukesh.rathor@xxxxxxxxxx>
Date: Fri, 16 Oct 2009 16:24:29 -0700
Cc:
Delivery-date: Fri, 16 Oct 2009 16:25:58 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] gdbsx: malloc extra bye for null char, Mukesh Rathor <=