git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Torsten Bögershausen" <tboegi@web.de>
To: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
Cc: "Torsten Bögershausen" <tboegi@web.de>,
	drizzd@aon.at, git@vger.kernel.org
Subject: Re: [PATCH] unpack-trees.c: check return value of lstat()
Date: Sun, 06 Mar 2011 20:50:15 +0100	[thread overview]
Message-ID: <4D73E577.1010604@web.de> (raw)
In-Reply-To: <vpqfwr0hwu0.fsf@bauges.imag.fr>

On 06.03.11 20:29, Matthieu Moy wrote:
> Torsten Bögershausen <tboegi@web.de> writes:
> 
>> +		if (!lstat(path, &st))
>> +			return check_ok_to_remove(path, len, DT_UNKNOWN, NULL, &st,
>> +			                          error_type, o);
>>  	} else if (!lstat(ce->name, &st))
> 
> What happens if lstat returns a non-0 value?
The result of "st" is 100% garbage, and should not be passed to anybody.
Not checking the return value (error or not) is not a good thing.
Developers might be tempted to write unreliable code...
> 
> Anyway, this seems to have been fixed by a93e53018 (Wed Jan 12 20:28:09
> 2011, unpack-trees: handle lstat failure for existing file) already.
> 
Hm,
v1.7.4 says:
commit e39212ab08e8d37dda5d8fd32b54099fe01dbbdb
Merge: 716958c 9e08273
(so far so good)
My git looks like this:

static int verify_absent_1(struct cache_entry *ce,
				 enum unpack_trees_error_types error_type,
				 struct unpack_trees_options *o)
{
[snip]
	else if (len > 0) {
		char path[PATH_MAX + 1];
		memcpy(path, ce->name, len);
		path[len] = 0;
		lstat(path, &st);
                ^^^^^^^^^^^^^^^^^^
		return check_ok_to_remove(path, len, DT_UNKNOWN, NULL, &st,
				error_type, o);


(And I had to correct drizzd@aon.a -> drizzd@aon.at)
/Torsten

  reply	other threads:[~2011-03-06 19:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-06 19:13 [PATCH] unpack-trees.c: check return value of lstat() Torsten Bögershausen
2011-03-06 19:29 ` Matthieu Moy
2011-03-06 19:50   ` Torsten Bögershausen [this message]
2011-03-06 20:57     ` Matthieu Moy
2011-03-07 15:59       ` Torsten Bögershausen

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=4D73E577.1010604@web.de \
    --to=tboegi@web.de \
    --cc=Matthieu.Moy@grenoble-inp.fr \
    --cc=drizzd@aon.at \
    --cc=git@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).