This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Fix for PR tdep/16397: SystemTap SDT probe support for x86 doesn't work with "triplet operands"
- From: Mark Kettenis <mark dot kettenis at xs4all dot nl>
- To: sergiodj at redhat dot com
- Cc: gdb-patches at sourceware dot org, brobecker at adacore dot com
- Date: Sun, 2 Feb 2014 18:07:30 +0100 (CET)
- Subject: Re: [PATCH] Fix for PR tdep/16397: SystemTap SDT probe support for x86 doesn't work with "triplet operands"
- Authentication-results: sourceware.org; auth=none
- References: <m3mwj1j12v dot fsf at redhat dot com> <m3a9eu70st dot fsf at redhat dot com> <m3vbx1fqkg dot fsf at redhat dot com> <201401301535 dot s0UFZp3N013895 at glazunov dot sibelius dot xs4all dot nl> <m38utt8omq dot fsf at redhat dot com>
> From: Sergio Durigan Junior <sergiodj@redhat.com>
> Date: Sun, 02 Feb 2014 14:29:01 -0200
>
> On Thursday, January 30 2014, Mark Kettenis wrote:
>
> >> From: Sergio Durigan Junior <sergiodj@redhat.com>
> >> Date: Thu, 30 Jan 2014 13:16:15 -0200
> >>
> >> On Friday, January 17 2014, I wrote:
> >>
> >> > On Sunday, January 12 2014, I wrote:
> >> >
> >> >> Hi,
> >> >>
> >> >> This is the continuation of what Joel proposed on:
> >> >>
> >> >> <https://sourceware.org/ml/gdb-patches/2013-12/msg00977.html>
> >> >
> >> > Ping.
> >>
> >> Ping^2.
> >
> > No objection to this going in (other than the unsafe use of
> > isdigit(3))
>
> Could you be more specific about the unsafe use of isdigit?
char *s;
...
if (isdigit(*s)) ...;
On most platforms chars are signed. The argument of isdigit(3) is
(signed) int. If *s is outside the 7-bi ASCII range, it will be
negative. The conversion to int will not change this. But calling
isdigit(3) with an argument that isn't in the range 0-255 and isn't
EOF (-1) is undefined. Many C libraries will do a range check, but a
naive (but standards conforming) implementation might just look at a
negative array index and crash your program.
The correct way to use these functions in code like this is to
explicitly cast the argument to unsigned char.
Cheers,
Mark