Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2018-06-10 13:56:31 +0300
committerJunio C Hamano <gitster@pobox.com>2018-06-18 20:03:38 +0300
commit94eff2b69a3dc662edac9984a08241d033e764d7 (patch)
tree10c554181a92b312049adc5535d0d53edfa2717b
parent1de70dbd1ada0069d1b6cd6345323906cc9a9ed3 (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>
-rw-r--r--merge-recursive.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/merge-recursive.c b/merge-recursive.c
index 13b4762971..16d2377b71 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -2017,18 +2017,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,