Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: gdb-patches@sourceware.org
Subject: [patch] [gdbserver] Fix memory corruption
Date: Tue, 01 Mar 2011 21:34:00 -0000	[thread overview]
Message-ID: <20110301213428.GA15991@host1.dyn.jankratochvil.net> (raw)

Hi,

gdb.server/ext-run.exp always crashes during the nightly regression tests:
	info os processes
	memory clobbered past end of allocated block
	Remote communication error.  Target disconnected.: Connection reset by peer.
	(gdb) FAIL: gdb.server/ext-run.exp: get process list (pattern 1)

Probably OK to check in but I rather ask.

To make it easily reproducible one can disable try_rle() by patching it:
+return 1;
   /* Don't go past '~'.  */

So that putpkt_binary_1's cnt == 16383 will overrun PBUFSIZ 16384 by 4 bytes.


Thanks,
Jan


gdb/gdbserver/
2011-03-01  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* remote-utils.c (putpkt_binary_1): Calculate BUF2 size dynamically.

--- a/gdb/gdbserver/remote-utils.c
+++ b/gdb/gdbserver/remote-utils.c
@@ -725,7 +725,7 @@ putpkt_binary_1 (char *buf, int cnt, int is_notif)
   char *p;
   int cc;
 
-  buf2 = xmalloc (PBUFSIZ);
+  buf2 = xmalloc (1 + cnt + 4);
 
   /* Copy the packet into buffer BUF2, encapsulating it
      and giving it a checksum.  */


             reply	other threads:[~2011-03-01 21:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-01 21:34 Jan Kratochvil [this message]
2011-03-02 15:35 ` Pedro Alves
2011-03-02 16:51   ` Jan Kratochvil
2011-03-02 18:00     ` Pedro Alves
2011-03-07 20:26       ` Jan Kratochvil

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=20110301213428.GA15991@host1.dyn.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox