Skip to content

Commit f72432d

Browse files
committed
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
2 parents 929c097 + 9da2d03 commit f72432d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

merge-recursive.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2211,18 +2211,18 @@ static struct hashmap *get_directory_renames(struct diff_queue_struct *pairs,
22112211
static struct dir_rename_entry *check_dir_renamed(const char *path,
22122212
struct hashmap *dir_renames)
22132213
{
2214-
char temp[PATH_MAX];
2214+
char *temp = xstrdup(path);
22152215
char *end;
2216-
struct dir_rename_entry *entry;
2216+
struct dir_rename_entry *entry = NULL;;
22172217

2218-
strcpy(temp, path);
22192218
while ((end = strrchr(temp, '/'))) {
22202219
*end = '\0';
22212220
entry = dir_rename_find_entry(dir_renames, temp);
22222221
if (entry)
2223-
return entry;
2222+
break;
22242223
}
2225-
return NULL;
2224+
free(temp);
2225+
return entry;
22262226
}
22272227

22282228
static void compute_collisions(struct hashmap *collisions,

0 commit comments

Comments
 (0)