From: "Torsten Bögershausen" <tboegi@web.de>
To: drizzd@aon.a, git@vger.kernel.org
Cc: tboegi@web.de
Subject: [PATCH] unpack-trees.c: check return value of lstat()
Date: Sun, 6 Mar 2011 20:13:52 +0100 [thread overview]
Message-ID: <201103062013.52793.tboegi@web.de> (raw)
Since commit f66caa "do not overwrite files in leading path"
at one place lstat() was called but the result was not checked.
Signed-off-by: Torsten Bögershausen <tboegi@web.de>
---
(While I was experimenting with something different,
this was found by valgrind)
Please review the patch, comments wellcome.
unpack-trees.c | 7 +++----
1 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/unpack-trees.c b/unpack-trees.c
index 1ca41b1..42f7aad 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -1374,10 +1374,9 @@ static int verify_absent_1(struct cache_entry *ce,
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);
+ if (!lstat(path, &st))
+ return check_ok_to_remove(path, len, DT_UNKNOWN, NULL, &st,
+ error_type, o);
} else if (!lstat(ce->name, &st))
return check_ok_to_remove(ce->name, ce_namelen(ce),
ce_to_dtype(ce), ce, &st,
--
1.7.4
next reply other threads:[~2011-03-06 19:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-06 19:13 Torsten Bögershausen [this message]
2011-03-06 19:29 ` [PATCH] unpack-trees.c: check return value of lstat() Matthieu Moy
2011-03-06 19:50 ` Torsten Bögershausen
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=201103062013.52793.tboegi@web.de \
--to=tboegi@web.de \
--cc=drizzd@aon.a \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.