summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0c80fdb)
raw | patch | inline | side by side (parent: 0c80fdb)
author | Johannes Schindelin <Johannes.Schindelin@gmx.de> | |
Tue, 11 Oct 2011 19:25:32 +0000 (14:25 -0500) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 11 Oct 2011 20:46:20 +0000 (13:46 -0700) |
The logic to check whether a file is a gitfile used the heuristics that
a gitfile cannot be larger than PATH_MAX or smaller than 10 bytes (as
its contents is "gitdir: " followed by a path) and returned early.
But it returned with a wrong value. It should have said "this cannot
possibly be a gitfile" by returning 0, but it returned 1 instead. 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("gitdir: ").
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
a gitfile cannot be larger than PATH_MAX or smaller than 10 bytes (as
its contents is "gitdir: " followed by a path) and returned early.
But it returned with a wrong value. It should have said "this cannot
possibly be a gitfile" by returning 0, but it returned 1 instead. 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("gitdir: ").
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
transport.c | patch | blob | history |
diff --git a/transport.c b/transport.c
index 1707c52446d5937a66c101c142931b3cc0465456..a2b1a258dc0b7ffd9d3988e65811e4e504808d90 100644 (file)
--- a/transport.c
+++ b/transport.c
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)