[PATCH] unpack-trees.c: check return value of lstat()
From: Torsten Bögershausen <hidden>
Date: 2016-06-15 22:50:43
Subsystem:
the rest · Maintainer:
Linus Torvalds
From: Torsten Bögershausen <hidden>
Date: 2016-06-15 22:50:43
Subsystem:
the rest · Maintainer:
Linus Torvalds
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 <redacted> --- (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