Make index preloading check the whole path to the file
This uses the new thread-safe 'threaded_has_symlink_leading_path()' function to efficiently verify that the whole path leading up to the filename is a proper path, and does not contain symlinks. This makes 'ce_uptodate()' a much stronger guarantee: it no longer just guarantees that the 'lstat()' of the path would match, it also means that we know that people haven't played games with moving directories around and covered it up with symlinks. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Linus Torvalds committed
Jul 9, 2009 at 13:37 UTC
f62ce3de9dd4803f50f65e17f5fc03c7bdb49c40
1 file changed
+4
preload-index.c
+4
@@ -34,7 +34,9 @@ static void *preload_thread(void *_data)
34
struct thread_data *p = _data;
35
struct index_state *index = p->index;
36
struct cache_entry **cep = index->cache + p->offset;
37
+ struct cache_def cache;
38
39
+ memset(&cache, 0, sizeof(cache));
40
nr = p->nr;
41
if (nr + p->offset > index->cache_nr)
42
nr = index->cache_nr - p->offset;
@@ -49,6 +51,8 @@ static void *preload_thread(void *_data)
51
continue;
52
if (!ce_path_match(ce, p->pathspec))
53
continue;
54
+ if (threaded_has_symlink_leading_path(&cache, ce->name, ce_namelen(ce)))
55
+ continue;
56
if (lstat(ce->name, &st))
57
continue;
58
if (ie_match_stat(index, ce, &st, CE_MATCH_RACY_IS_DIRTY))