Skip to content

Commit

Permalink
Make index preloading check the whole path to the file
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Linus Torvalds authored and Junio C Hamano committed Jul 10, 2009
1 parent b9fd284 commit f62ce3d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions preload-index.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ static void *preload_thread(void *_data)
struct thread_data *p = _data;
struct index_state *index = p->index;
struct cache_entry **cep = index->cache + p->offset;
struct cache_def cache;

memset(&cache, 0, sizeof(cache));
nr = p->nr;
if (nr + p->offset > index->cache_nr)
nr = index->cache_nr - p->offset;
Expand All @@ -49,6 +51,8 @@ static void *preload_thread(void *_data)
continue;
if (!ce_path_match(ce, p->pathspec))
continue;
if (threaded_has_symlink_leading_path(&cache, ce->name, ce_namelen(ce)))
continue;
if (lstat(ce->name, &st))
continue;
if (ie_match_stat(index, ce, &st, CE_MATCH_RACY_IS_DIRTY))
Expand Down

0 comments on commit f62ce3d

Please sign in to comment.