From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Pedro Alves <pedro@codesourcery.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [patch] [gdbserver] Fix memory corruption
Date: Mon, 07 Mar 2011 20:26:00 -0000 [thread overview]
Message-ID: <20110307201810.GA6188@host1.jankratochvil.net> (raw)
In-Reply-To: <201103021800.45824.pedro@codesourcery.com>
On Wed, 02 Mar 2011 19:00:45 +0100, Pedro Alves wrote:
> On Wednesday 02 March 2011 16:51:35, Jan Kratochvil wrote:
> > Before starting to chase off-by-one here and off-by-one there what is the
> > practical purpose of such strict packet limits?
>
> The remote protocol is designed to be implementable in tiny chips as
> well, where you typically have a static buffer for the incoming packet
> buffer. malloc is a luxury you don't have in many of those scenarios.
> So for outgoing packets, gdb needs to be careful about that. For
> incoming packets, gdb dynamically grows the buffer as it finds its
> receiving larger packets.
But FSF gdbserver can receive arbitrarily large packets and allocate
everything dynamically. It can also send arbitrarily large responses.
Thanks for the info, although for next updates, not this one.
> So I think your patch is indeed okay.
> I wouldn't mind a comment explaining the magic numbers, or replacing
> them with 'strlen ("$#NN")' like in remote.c:
Done.
Checked in.
Thanks,
Jan
http://sourceware.org/ml/gdb-cvs/2011-03/msg00106.html
--- src/gdb/gdbserver/ChangeLog 2011/03/06 07:40:52 1.465
+++ src/gdb/gdbserver/ChangeLog 2011/03/07 20:15:12 1.466
@@ -1,3 +1,7 @@
+2011-03-07 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * remote-utils.c (putpkt_binary_1): Calculate BUF2 size dynamically.
+
2011-03-06 Yao Qi <yao@codesourcery.com>
* Makefile.in (REQUIRED_SUBDIRS): Remove $(LIBCOMMON_DIR).
--- src/gdb/gdbserver/remote-utils.c 2011/01/25 10:09:19 1.84
+++ src/gdb/gdbserver/remote-utils.c 2011/03/07 20:15:12 1.85
@@ -725,7 +725,7 @@
char *p;
int cc;
- buf2 = xmalloc (PBUFSIZ);
+ buf2 = xmalloc (strlen ("$") + cnt + strlen ("#nn") + 1);
/* Copy the packet into buffer BUF2, encapsulating it
and giving it a checksum. */
prev parent reply other threads:[~2011-03-07 20:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-01 21:34 Jan Kratochvil
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 [this message]
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=20110307201810.GA6188@host1.jankratochvil.net \
--to=jan.kratochvil@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=pedro@codesourcery.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox