From f0e86b3b664bbfdc7e8fabdb01518347f7e0d2f8 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 11 Oct 2011 14:07:48 -0500 Subject: [PATCH] Fix is_gitfile() for files larger than PATH_MAX MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- transport.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/transport.c b/transport.c index f3195c0ae4..57138d908a 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)