aboutsummaryrefslogtreecommitdiff
path: root/merge-recursive.c
diff options
context:
space:
mode:
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>2006-07-30 18:35:21 +0200
committerJunio C Hamano <junkio@cox.net>2006-07-30 14:23:00 -0700
commitf59aac47f3839367d0da04019b0fc2bd61345225 (patch)
treec60498c9bb8288133e219a1b6112235ed71fe7b9 /merge-recursive.c
parenta060b803b49c04cd6e3b0d859f131349dab6b26f (diff)
downloadgit-f59aac47f3839367d0da04019b0fc2bd61345225.tar.gz
git-f59aac47f3839367d0da04019b0fc2bd61345225.tar.xz
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>
Diffstat (limited to 'merge-recursive.c')
-rw-r--r--merge-recursive.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/merge-recursive.c b/merge-recursive.c
index 6a796f24c..5375a1ba3 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -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)