diff options
author | René Scharfe <l.s.r@web.de> | 2018-06-10 13:56:31 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-06-14 18:56:35 +0300 |
commit | 9da2d0379ea0220dd670d70b8af571a2a09b3c12 (patch) | |
tree | 73d0ddfd46a7b5c7d4f127fcb6db887ddc5e4385 /merge-recursive.c | |
parent | c5b761fb2711542073cf1906c0e86a34616b79ae (diff) |
merge-recursive: use xstrdup() instead of fixed buffer
Paths can be longer than PATH_MAX. Avoid a buffer overrun in
check_dir_renamed() by using xstrdup() to make a private copy safely.
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'merge-recursive.c')
-rw-r--r-- | merge-recursive.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/merge-recursive.c b/merge-recursive.c index 5f42c677d5..7ea70c4a9d 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -1938,18 +1938,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, |