This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix for PR tdep/16397: SystemTap SDT probe support for x86 doesn't work with "triplet operands"


> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]