From: Joel Brobecker <brobecker@adacore.com>
To: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [patch] Fix -fsanitize=address on unreadable inferior strings
Date: Tue, 19 Aug 2014 06:54:00 -0000 [thread overview]
Message-ID: <20140819065422.GE1773@adacore.com> (raw)
In-Reply-To: <20140818192747.GA23790@host2.jankratochvil.net>
> gdb/
> 2014-08-18 Jan Kratochvil <jan.kratochvil@redhat.com>
>
> Fix -fsanitize=address on unreadable inferior strings.
> * valprint.c (val_print_string): Fix access before BUFFER.
LGTM. I actually don't see why this wouldn't be a possible bug.
Couldn't LEN be 0, in which case BYTES_READ would be zero, making
WIDTH > BYTES_READ?
>
> diff --git a/gdb/valprint.c b/gdb/valprint.c
> index d3ab267..a87d67c 100644
> --- a/gdb/valprint.c
> +++ b/gdb/valprint.c
> @@ -2510,8 +2510,10 @@ val_print_string (struct type *elttype, const char *encoding,
> LEN is -1. */
>
> /* Determine found_nul by looking at the last character read. */
> - found_nul = extract_unsigned_integer (buffer + bytes_read - width, width,
> - byte_order) == 0;
> + found_nul = 0;
> + if (bytes_read >= width)
> + found_nul = extract_unsigned_integer (buffer + bytes_read - width, width,
> + byte_order) == 0;
> if (len == -1 && !found_nul)
> {
> gdb_byte *peekbuf;
--
Joel
next prev parent reply other threads:[~2014-08-19 6:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-18 19:27 Jan Kratochvil
2014-08-19 6:54 ` Joel Brobecker [this message]
2014-08-19 14:16 ` Jan Kratochvil
2014-08-19 20:56 ` [commit] " 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=20140819065422.GE1773@adacore.com \
--to=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
--cc=jan.kratochvil@redhat.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