Commit 2d36e145d9acc25e6368d3be41546275a9185c24

Carlos Martín Nieto 2015-12-03T23:37:37

Merge pull request #3534 from ethomson/index_canonicalize_fix index: canonicalize inserted paths safely

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/src/index.c b/src/index.c
index ca5b2c4..391738e 100644
--- a/src/index.c
+++ b/src/index.c
@@ -1167,7 +1167,7 @@ static int canonicalize_directory_path(
 		while ((match = git_vector_get(&index->entries, pos))) {
 			if (GIT_IDXENTRY_STAGE(match) != 0) {
 				/* conflicts do not contribute to canonical paths */
-			} else if (memcmp(search, match->path, search_len) == 0) {
+			} else if (strncmp(search, match->path, search_len) == 0) {
 				/* prefer an exact match to the input filename */
 				best = match;
 				best_len = search_len;