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

[PATCH] Fix is_gitfile() for files larger than PATH_MAX

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Oct 11, 2011, 19:25 UTC
Message-ID
<alpine.DEB.1.00.1110111424010.32316@s15462909.onlinehome-server.info>

The logic to check whether a file is a gitfile used the heuristics that the file cannot be larger than PATH_MAX. But in that case it returned the wrong value. Our test cases do not cover this, as the bundle files produced are smaller than PATH_MAX. Except on Windows.

While at it, fix the faulty logic that the path stored in a gitfile cannot be larger than PATH_MAX-sizeof("gitfile: ").

Problem identified by running the test suite in msysGit, offending commit identified by Jörg Rosenkranz.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
	This patch should apply cleanly to 'next', which we track in
	msysgit/git.
	The task of adding a test case is something I leave to someone who
	wants to get involved with Git development and needs an easy way
	in.
 transport.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/transport.c b/transport.c
index f3195c0..57138d9 100644
--- a/transport.c
+++ b/transport.c
@@ -868,8 +868,8 @@ static int is_gitfile(const char *url)
 		return 0;
 	if (!S_ISREG(st.st_mode))
 		return 0;
-	if (st.st_size < 10 || st.st_size > PATH_MAX)
-		return 1;
+	if (st.st_size < 10 || st.st_size > 9 + PATH_MAX)
+		return 0;
 
 	fd = open(url, O_RDONLY);
 	if (fd < 0)
-- 
1.7.6.msysgit.0.584.g2cbf
Next: Junio C Hamano
Message 1 of 4 in “Fix is_gitfile() for files larger than PATH_MAX”
  1. Fix is_gitfile() for files larger than PATH_MAXJohannes Schindelin, Oct 11, 2011
  2. Junio C HamanoOct 11, 2011
  3. Phil HordOct 11, 2011
  4. Phil HordOct 11, 2011

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.