git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] unpack-trees.c: check return value of lstat()
@ 2011-03-06 19:13 Torsten Bögershausen
  2011-03-06 19:29 ` Matthieu Moy
  0 siblings, 1 reply; 5+ messages in thread
From: Torsten Bögershausen @ 2011-03-06 19:13 UTC (permalink / raw)
  To: drizzd, git; +Cc: tboegi

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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-03-07 15:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2011-03-06 20:57     ` Matthieu Moy
2011-03-07 15:59       ` Torsten Bögershausen

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).