All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mukesh Rathor <mukesh.rathor@oracle.com>
To: "Xen-devel@lists.xensource.com" <Xen-devel@lists.xensource.com>
Subject: [PATCH] gdbsx: malloc extra bye for null char
Date: Fri, 16 Oct 2009 16:24:29 -0700	[thread overview]
Message-ID: <20091016162429.0b034fc4@mantra.us.oracle.com> (raw)


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@oracle.com>

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;
     }

                 reply	other threads:[~2009-10-16 23:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091016162429.0b034fc4@mantra.us.oracle.com \
    --to=mukesh.rathor@oracle.com \
    --cc=Xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.