summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-11-03 23:32:40 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-11-03 23:32:40 (GMT)
commit3a27eec48ecfcc0764c90b3f478a124c01c082bc (patch)
tree792ef7ba9534ad1cc1a76a06cde16e8d8f3f3dd8 /dir.c
parentced2321a8df8260e7d22e72e2bb5b8c6ab3f2180 (diff)
parent41284eb0f944fe2d73708bb4105a8e3ccd0297df (diff)
downloadgit-3a27eec48ecfcc0764c90b3f478a124c01c082bc.zip
git-3a27eec48ecfcc0764c90b3f478a124c01c082bc.tar.gz
git-3a27eec48ecfcc0764c90b3f478a124c01c082bc.tar.bz2
Merge branch 'dt/name-hash-dir-entry-fix' into maint
The name-hash subsystem that is used to cope with case insensitive filesystems keeps track of directories and their on-filesystem cases for all the paths in the index by holding a pointer to a randomly chosen cache entry that is inside the directory (for its ce->ce_name component). This pointer was not updated even when the cache entry was removed from the index, leading to use after free. This was fixed by recording the path for each directory instead of borrowing cache entries and restructuring the API somewhat. * dt/name-hash-dir-entry-fix: name-hash: don't reuse cache_entry in dir_entry
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c22
1 files changed, 4 insertions, 18 deletions
diff --git a/dir.c b/dir.c
index 118ba59..88e8958 100644
--- a/dir.c
+++ b/dir.c
@@ -1202,29 +1202,15 @@ enum exist_status {
*/
static enum exist_status directory_exists_in_index_icase(const char *dirname, int len)
{
- const struct cache_entry *ce = cache_dir_exists(dirname, len);
- unsigned char endchar;
+ struct cache_entry *ce;
- if (!ce)
- return index_nonexistent;
- endchar = ce->name[len];
-
- /*
- * The cache_entry structure returned will contain this dirname
- * and possibly additional path components.
- */
- if (endchar == '/')
+ if (cache_dir_exists(dirname, len))
return index_directory;
- /*
- * If there are no additional path components, then this cache_entry
- * represents a submodule. Submodules, despite being directories,
- * are stored in the cache without a closing slash.
- */
- if (!endchar && S_ISGITLINK(ce->ce_mode))
+ ce = cache_file_exists(dirname, len, ignore_case);
+ if (ce && S_ISGITLINK(ce->ce_mode))
return index_gitdir;
- /* This should never be hit, but it exists just in case. */
return index_nonexistent;
}