git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Alex Riesen" <raa.lkml@gmail.com>
To: "Jim Meyering" <jim@meyering.net>
Cc: git@vger.kernel.org
Subject: Re: unchecked uses of strdup
Date: Thu, 6 Apr 2006 16:11:22 +0200	[thread overview]
Message-ID: <81b0412b0604060711o57fb110cm5fa559c0fd785a66@mail.gmail.com> (raw)
In-Reply-To: <87d5fwau3z.fsf_-_@rho.meyering.net>

On 4/5/06, Jim Meyering <jim@meyering.net> wrote:
> There are pretty many uses of strdup in git's sources.
> Here's one that can cause trouble if it ever returns NULL:
>
>     [from fsck-objects.c]
>     static int fsck_head_link(void)
>     {
>             unsigned char sha1[20];
>             const char *git_HEAD = strdup(git_path("HEAD"));
>             const char *git_refs_heads_master = resolve_ref(git_HEAD, sha1, 1);
>
> The problem is that resolve_ref does an unconditional `stat'
> on the parameter corresponding to the maybe-NULL git_HEAD.

That's actually alright (aside a nice core file). Worse are the cases
where a NULL would cause some "normal" behaviour, e.g. arguments,
which have a meaning for NULL value.

  reply	other threads:[~2006-04-06 14:11 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-03 22:18 [PATCH] Add git-clean command Pavel Roskin
2006-04-04  0:06 ` Junio C Hamano
2006-04-04 10:58   ` Sam Ravnborg
2006-04-04 15:52     ` Pavel Roskin
2006-04-05 16:02       ` unchecked uses of strdup Jim Meyering
2006-04-06 14:11         ` Alex Riesen [this message]
2006-04-05  6:00   ` [PATCH] Add git-clean command Pavel Roskin
2006-04-04  8:20 ` Martin Waitz
2006-04-04  9:08   ` Junio C Hamano
2006-04-04  9:17   ` Alex Riesen
2006-04-04 15:32     ` Pavel Roskin

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=81b0412b0604060711o57fb110cm5fa559c0fd785a66@mail.gmail.com \
    --to=raa.lkml@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=jim@meyering.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 NNTP newsgroup(s).