Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
merge-recursive: use xstrdup() instead of fixed buffer
author
René Scharfe
<l.s.r@web.de>
Sun, 10 Jun 2018 10:56:31 +0000
(12:56 +0200)
committer
Junio C Hamano
<gitster@pobox.com>
Mon, 18 Jun 2018 17:03:38 +0000
(10:03 -0700)
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>
merge-recursive.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
1de70db
)
diff --git
a/merge-recursive.c
b/merge-recursive.c
index 13b47629719022c0e5d1311a1c7c3cd905936700..16d2377b71bf40ae88fa5ffd5863105a40e6c96b 100644
(file)
--- 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)
{
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;
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)
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,
}
static void compute_collisions(struct hashmap *collisions,