summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-06-18 17:18:44 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-06-18 17:18:44 (GMT)
commitf72432d64ebc4fea80265114464ddb7b25ce9633 (patch)
tree55cbf9cbf94453a90be00ccbb36fb1a37f9d6f73
parent929c0975482e78c4bd680b010a8ceac6c31160a0 (diff)
parent9da2d0379ea0220dd670d70b8af571a2a09b3c12 (diff)
downloadgit-f72432d64ebc4fea80265114464ddb7b25ce9633.zip
git-f72432d64ebc4fea80265114464ddb7b25ce9633.tar.gz
git-f72432d64ebc4fea80265114464ddb7b25ce9633.tar.bz2
Merge branch 'en/rename-directory-detection'
Newly added codepath in merge-recursive had potential buffer overrun, which has been fixed. * en/rename-directory-detection: merge-recursive: use xstrdup() instead of fixed buffer
-rw-r--r--merge-recursive.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/merge-recursive.c b/merge-recursive.c
index 5eb907f..f110e1c 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -2211,18 +2211,18 @@ static struct hashmap *get_directory_renames(struct diff_queue_struct *pairs,
static struct dir_rename_entry *check_dir_renamed(const char *path,
struct hashmap *dir_renames)
{
- char temp[PATH_MAX];
+ char *temp = xstrdup(path);
char *end;
- struct dir_rename_entry *entry;
+ struct dir_rename_entry *entry = NULL;;
- strcpy(temp, path);
while ((end = strrchr(temp, '/'))) {
*end = '\0';
entry = dir_rename_find_entry(dir_renames, temp);
if (entry)
- return entry;
+ break;
}
- return NULL;
+ free(temp);
+ return entry;
}
static void compute_collisions(struct hashmap *collisions,