]> asedeno.scripts.mit.edu Git - git.git/commitdiff
merge-recur: fix thinko in unique_path()
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>
Sun, 30 Jul 2006 16:35:21 +0000 (18:35 +0200)
committerJunio C Hamano <junkio@cox.net>
Sun, 30 Jul 2006 21:23:00 +0000 (14:23 -0700)
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>
merge-recursive.c

index 6a796f24c7f3cdba2c6c2dc1c93bdfcd0c5c2ea1..5375a1ba307e866f23900d9088f06e21ae5c997d 100644 (file)
@@ -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)