提交 9da2d037 编写于 作者: R René Scharfe 提交者: Junio C Hamano

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: NRene Scharfe <l.s.r@web.de>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 c5b761fb
......@@ -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,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册