From: "Andrew Burgess" <aburgess@broadcom.com>
To: gdb-patches@sourceware.org
Cc: "Andreas Schwab" <schwab@linux-m68k.org>, Paul_Koning@Dell.com
Subject: Re: [PATCH] Don't call strchr with the NULL character.
Date: Fri, 12 Jul 2013 09:18:00 -0000 [thread overview]
Message-ID: <51DFC9C6.2060806@broadcom.com> (raw)
In-Reply-To: <51DEDA0E.8020809@broadcom.com>
On 11/07/2013 5:15 PM, Andrew Burgess wrote:
> In the printf code we call strchr without guarding against the
> case where the second parameter is NULL.
>
> My local manpage for strchr doesn't say what happens in this case,
> but this file: src/libiberty/strchr.c
> suggests the results are undefined, and indeed, the answer I see is
> not NULL (which is what I might have hoped for).
Thanks to both Andreas and Paul for pointing out more up to
date manual pages that explain the behaviour is NOT undefined
at all.
That said, my patch (I believe) fixes gdb given the /current/
behaviour, which I thought was undefined, but is in fact well
defined. Either way I believe this patch is required.
Here's an example from before my patch:
while (strchr ("0-+ #", *f))
{
if (*f == '#')
seen_hash = 1;
else if (*f == '0')
seen_zero = 1;
else if (*f == ' ')
seen_space = 1;
else if (*f == '+')
seen_plus = 1;
f++;
}
If *f is the end of string NULL character then the loop
above will run off the end of the string.
Thanks,
Andrew
next prev parent reply other threads:[~2013-07-12 9:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-11 16:15 Andrew Burgess
2013-07-11 16:24 ` Andreas Schwab
2013-07-11 16:48 ` Paul_Koning
2013-07-12 9:18 ` Andrew Burgess [this message]
2013-07-16 17:36 ` Tom Tromey
2013-07-16 21:16 ` Andrew Burgess
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=51DFC9C6.2060806@broadcom.com \
--to=aburgess@broadcom.com \
--cc=Paul_Koning@Dell.com \
--cc=gdb-patches@sourceware.org \
--cc=schwab@linux-m68k.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