mirror of
https://github.com/git/git
synced 2024-08-24 18:26:02 +00:00
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>
This commit is contained in:
parent
1de70dbd1a
commit
94eff2b69a
|
@ -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,
|
static struct dir_rename_entry *check_dir_renamed(const char *path,
|
||||||
struct hashmap *dir_renames)
|
struct hashmap *dir_renames)
|
||||||
{
|
{
|
||||||
char temp[PATH_MAX];
|
char *temp = xstrdup(path);
|
||||||
char *end;
|
char *end;
|
||||||
struct dir_rename_entry *entry;
|
struct dir_rename_entry *entry = NULL;;
|
||||||
|
|
||||||
strcpy(temp, path);
|
|
||||||
while ((end = strrchr(temp, '/'))) {
|
while ((end = strrchr(temp, '/'))) {
|
||||||
*end = '\0';
|
*end = '\0';
|
||||||
entry = dir_rename_find_entry(dir_renames, temp);
|
entry = dir_rename_find_entry(dir_renames, temp);
|
||||||
if (entry)
|
if (entry)
|
||||||
return entry;
|
break;
|
||||||
}
|
}
|
||||||
return NULL;
|
free(temp);
|
||||||
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void compute_collisions(struct hashmap *collisions,
|
static void compute_collisions(struct hashmap *collisions,
|
||||||
|
|
Loading…
Reference in a new issue