Skip to content

Commit f0e86b3

Browse files
committed
Fix is_gitfile() for files larger than PATH_MAX
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 <[email protected]>
1 parent 2e51681 commit f0e86b3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

transport.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -868,8 +868,8 @@ static int is_gitfile(const char *url)
868868
return 0;
869869
if (!S_ISREG(st.st_mode))
870870
return 0;
871-
if (st.st_size < 10 || st.st_size > PATH_MAX)
872-
return 1;
871+
if (st.st_size < 10 || st.st_size > 9 + PATH_MAX)
872+
return 0;
873873

874874
fd = open(url, O_RDONLY);
875875
if (fd < 0)

0 commit comments

Comments
 (0)