diff options
author | Junio C Hamano <gitster@pobox.com> | 2018-06-18 10:18:44 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-06-18 10:18:44 -0700 |
commit | f72432d64ebc4fea80265114464ddb7b25ce9633 (patch) | |
tree | 55cbf9cbf94453a90be00ccbb36fb1a37f9d6f73 | |
parent | Merge branch 'rd/doc-remote-tracking-with-hyphen' (diff) | |
parent | merge-recursive: use xstrdup() instead of fixed buffer (diff) | |
download | tgif-f72432d64ebc4fea80265114464ddb7b25ce9633.tar.xz |
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.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/merge-recursive.c b/merge-recursive.c index 5eb907f46e..f110e1c5ec 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, |