Browse Source

merge-recur: fix thinko in unique_path()

This could result in a nasty infinite loop, or in bogus names (it used
the strlen() of the newly allocated buffer instead of the original
buffer).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
maint
Johannes Schindelin 19 years ago committed by Junio C Hamano
parent
commit
f59aac47f3
  1. 4
      merge-recursive.c

4
merge-recursive.c

@ -477,9 +477,9 @@ static char *unique_path(const char *path, const char *branch) @@ -477,9 +477,9 @@ static char *unique_path(const char *path, const char *branch)
char *newpath = xmalloc(strlen(path) + 1 + strlen(branch) + 8 + 1);
int suffix = 0;
struct stat st;
char *p = newpath + strlen(newpath);
char *p = newpath + strlen(path);
strcpy(newpath, path);
strcat(newpath, "~");
*(p++) = '~';
strcpy(p, branch);
for (; *p; ++p)
if ('/' == *p)

Loading…
Cancel
Save