summaryrefslogtreecommitdiff
path: root/read-cache.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-10-29 13:59:19 -0700
committerJunio C Hamano <gitster@pobox.com>2015-10-29 13:59:19 -0700
commit69fe31887bf8be496bb0adb4db3150cec52e1a2c (patch)
tree4e9040a5fa5d0fe7ae4b62ab11c6b55723b77f4c /read-cache.c
parent433cc7e3fb861d4530ca6c49b152e94219bddfda (diff)
parent41284eb0f944fe2d73708bb4105a8e3ccd0297df (diff)
downloadgit-69fe31887bf8be496bb0adb4db3150cec52e1a2c.tar.gz
Merge branch 'dt/name-hash-dir-entry-fix'
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 'read-cache.c')
-rw-r--r--read-cache.c16
1 files changed, 1 insertions, 15 deletions
diff --git a/read-cache.c b/read-cache.c
index 3ecb99dd2f..84616c8e21 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -678,21 +678,7 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,
* entry's directory case.
*/
if (ignore_case) {
- const char *startPtr = ce->name;
- const char *ptr = startPtr;
- while (*ptr) {
- while (*ptr && *ptr != '/')
- ++ptr;
- if (*ptr == '/') {
- struct cache_entry *foundce;
- ++ptr;
- foundce = index_dir_exists(istate, ce->name, ptr - ce->name - 1);
- if (foundce) {
- memcpy((void *)startPtr, foundce->name + (startPtr - ce->name), ptr - startPtr);
- startPtr = ptr;
- }
- }
- }
+ adjust_dirname_case(istate, ce->name);
}
alias = index_file_exists(istate, ce->name, ce_namelen(ce), ignore_case);