Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: <Paul_Koning@Dell.com>
To: <aburgess@broadcom.com>
Cc: <gdb-patches@sourceware.org>
Subject: Re: [PATCH] Don't call strchr with the NULL character.
Date: Thu, 11 Jul 2013 16:48:00 -0000	[thread overview]
Message-ID: <C75A84166056C94F84D238A44AF9F6AD0344FEBF@AUSX10MPC102.AMER.DELL.COM> (raw)
In-Reply-To: <51DEDA0E.8020809@broadcom.com>


On Jul 11, 2013, at 12: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).

The BSD manpage (for example on Mac OS) says:
     The strchr() function locates the first occurrence of c (converted to a
     char) in the string pointed to by s.  The terminating null character is
     considered to be part of the string; therefore if c is `\0', the func-
     tions locate the terminating `\0'.

It looks like libiberty/strchr.c does the same thing.  It doesn't look undefined at all. 

	paul


  parent reply	other threads:[~2013-07-11 16:48 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 [this message]
2013-07-12  9:18 ` Andrew Burgess
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=C75A84166056C94F84D238A44AF9F6AD0344FEBF@AUSX10MPC102.AMER.DELL.COM \
    --to=paul_koning@dell.com \
    --cc=aburgess@broadcom.com \
    --cc=gdb-patches@sourceware.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