Skip to content

Commit f62ce3d

Browse files
torvaldsgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b9fd284 commit f62ce3d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

preload-index.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ static void *preload_thread(void *_data)
3434
struct thread_data *p = _data;
3535
struct index_state *index = p->index;
3636
struct cache_entry **cep = index->cache + p->offset;
37+
struct cache_def cache;
3738

39+
memset(&cache, 0, sizeof(cache));
3840
nr = p->nr;
3941
if (nr + p->offset > index->cache_nr)
4042
nr = index->cache_nr - p->offset;
@@ -49,6 +51,8 @@ static void *preload_thread(void *_data)
4951
continue;
5052
if (!ce_path_match(ce, p->pathspec))
5153
continue;
54+
if (threaded_has_symlink_leading_path(&cache, ce->name, ce_namelen(ce)))
55+
continue;
5256
if (lstat(ce->name, &st))
5357
continue;
5458
if (ie_match_stat(index, ce, &st, CE_MATCH_RACY_IS_DIRTY))

0 commit comments

Comments
 (0)