public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <dan@codesourcery.com>
To: Ali Lakhia <lakhia@alumni.utexas.net>
Cc: gdb-patches@sourceware.org
Subject: Re: [patch] [trivial] fix NULL deref
Date: Thu, 16 Sep 2010 19:17:00 -0000	[thread overview]
Message-ID: <20100916175122.GA18399@caradoc.them.org> (raw)
In-Reply-To: <AANLkTikJnzZjGd0LsBMm2TifpkAjvjJ+qDRkQ-qmz9dx@mail.gmail.com>

On Thu, Sep 16, 2010 at 10:26:27AM -0700, Ali Lakhia wrote:
> Please see patch to fix NULL dereference in strchr() function. Thanks.

Interesting.  How did you find this problem?  I don't think this
function can ever be called.

> 
> -Ali
> 
> --- gdb-7.1/gdb/fork-child.c    2009-12-31 23:31:31.000000000 -0800
> +++ gdb-7.1/gdb/fork-child.c 2010-09-16 10:17:25.000000000 -0700
> @@ -52,7 +52,7 @@
>  static void
>  breakup_args (char *scratch, char **argv)
>  {
> -  char *cp = scratch;
> +  char *cp = scratch, *tmp;
> 
>    for (;;)
>      {
> @@ -68,15 +68,16 @@
>        *argv++ = cp;
> 
>        /* Scan for next arg separator.  */
> -      cp = strchr (cp, ' ');
> -      if (cp == NULL)
> -       cp = strchr (cp, '\t');
> -      if (cp == NULL)
> -       cp = strchr (cp, '\n');
> +      tmp = strchr (cp, ' ');
> +      if (tmp == NULL)
> +       tmp = strchr (cp, '\t');
> +      if (tmp == NULL)
> +       tmp = strchr (cp, '\n');
> 
>        /* No separators => end of string => break.  */
> -      if (cp == NULL)
> +      if (tmp == NULL)
>         break;
> +      cp = tmp;
> 
>        /* Replace the separator with a terminator.  */
>        *cp++ = '\0';
> 

-- 
Daniel Jacobowitz
CodeSourcery

  reply	other threads:[~2010-09-16 17:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-16 18:30 Ali Lakhia
2010-09-16 19:17 ` Daniel Jacobowitz [this message]
2010-09-16 19:21   ` Ali Lakhia
2010-09-30 18:53     ` Ali Lakhia
2010-09-30 18:57       ` Michael Snyder
2010-09-30 19:01         ` Joel Brobecker
     [not found]         ` <AANLkTi=eko07y=CDdWpsr_7ZZvd=FHYjc-uo4v8SLd6E@mail.gmail.com>
2010-10-01 17:36           ` Michael Snyder

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=20100916175122.GA18399@caradoc.them.org \
    --to=dan@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    --cc=lakhia@alumni.utexas.net \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).