Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Michael Snyder <msnyder@vmware.com>
To: Pedro Alves <pedro@codesourcery.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [commit] objc-lang.c: avoid string overrun
Date: Mon, 28 Feb 2011 18:27:00 -0000	[thread overview]
Message-ID: <4D6BE6C1.7050502@vmware.com> (raw)
In-Reply-To: <201102280951.19458.pedro@codesourcery.com>

Pedro Alves wrote:
> On Monday 28 February 2011 02:15:47, Michael Snyder wrote:
>>         {
>> -         strcpy(myregexp, regexp);
>> +         strncpy(myregexp, regexp, sizeof (myregexp) - 1);
> 
> Such fixes ain't that much better.  At the bare least, you'd
> need to null terminate the result, as strncpy does not do that
> for you if REGEXP is large enough --- strncpy was not
> designed as a safe strcpy.  And then proceeding as if nothing
> happened when `myregexp' isn't large enough is just b0rked.
> 
>>           if (myregexp[strlen(myregexp) - 1] == '$') /* end of selector */
>>             myregexp[strlen(myregexp) - 1] = ']';    /* end of method name */
> 

Yes, Jan provided a more complete fix.


      reply	other threads:[~2011-02-28 18:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-28  4:10 Michael Snyder
2011-02-28  4:52 ` Jan Kratochvil
2011-02-28 18:02   ` Michael Snyder
2011-02-28 18:15     ` Jan Kratochvil
2011-02-28 12:21 ` Pedro Alves
2011-02-28 18:27   ` Michael Snyder [this message]

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=4D6BE6C1.7050502@vmware.com \
    --to=msnyder@vmware.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@codesourcery.com \
    /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