git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jul 30, 2006, 16:35 UTC
Message-ID
<Pine.LNX.4.63.0607301835020.29667@wbgn013.biozentrum.uni-wuerzburg.de>

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
Message 1 of 1 in “merge-recur: fix thinko in unique_path()”
  1. merge-recur: fix thinko in unique_path()Johannes Schindelin, Jul 30, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.