[PATCH] merge-recur: fix thinko in unique_path()

From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Date: 2006-07-31 02:35:21
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>
---
 merge-recursive.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/merge-recursive.c b/merge-recursive.c
index 6a796f2..5375a1b 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -477,9 +477,9 @@ static char *unique_path(const char *pat
 	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)
-- 
1.4.2.rc2.geb7f

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Received on Mon Jul 31 02:36:00 2006

This archive was generated by hypermail 2.1.8 : 2006-07-31 02:36:29 EST