git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alex Riesen <raa.lkml@gmail.com>
To: Steven Michalske <smichalske@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Use strncpy to protect from buffer overruns.
Date: Wed, 9 Jun 2010 14:44:51 +0200	[thread overview]
Message-ID: <AANLkTikID-cEqdDD8XEEYmClSYEkcxdAU-rjYA2LoRVe@mail.gmail.com> (raw)
In-Reply-To: <1276078921-25429-1-git-send-email-smichalske@gmail.com>

On Wed, Jun 9, 2010 at 12:22, Steven Michalske <smichalske@gmail.com> wrote:
> is_git_directory() uses strcpy with pointer arithmitic, protect it from
> overflowing.  Even though we currently protect higher up when we have the
> environment variable path passed in, we should protect the calls here.

Why? The function is static.

> -       strcpy(path, suspect);
> +       path[sizeof(path) - 1] = '\0';
> +
> +       strncpy(path, suspect, sizeof(path) - 1);

And we have strlcpy for such things.

  reply	other threads:[~2010-06-09 12:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-09 10:22 [PATCH] Use strncpy to protect from buffer overruns Steven Michalske
2010-06-09 12:44 ` Alex Riesen [this message]
2010-06-09 18:25   ` Steven Michalske
2010-06-09 19:31     ` Alex Riesen
2010-06-09 20:42       ` Steven Michalske

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=AANLkTikID-cEqdDD8XEEYmClSYEkcxdAU-rjYA2LoRVe@mail.gmail.com \
    --to=raa.lkml@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=smichalske@gmail.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;
as well as URLs for NNTP newsgroup(s).