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

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

From
Phil Hord <phil.hord@gmail.com>
Date
Oct 11, 2011, 20:58 UTC
Message-ID
<CABURp0ru7aCW_oUZO8eaFpau5DAHDgwWLqHSL1QMjbUDkqrANg@mail.gmail.com>
In-Reply-To
<7vy5wre0n7.fsf@alter.siamese.dyndns.org>
On Tue, Oct 11, 2011 at 4:25 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 20 quoted lines
>> @@ -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;
>
> We are asked if the file is likely to be a single-liner "gitfile: <path>",
> and were answering yes when it is a very short file (less than 10 bytes)
> that cannot possibly even contain "gitfile: " prefix.
>
> I suspect that we can and should get rid of the "cannot be very long"
> check altogether---we do open and check the file, and after all it is not
> like we are throwing different strings as "url" argument to this function
> at random and this function needs heuristics to reject bogus input
> early. The argument is an input from the user.
>
> Quite an embarrasing bug. Thanks for spotting.

Yes, and it's _my_ embarrassing bug. I've caught this and have it in a re-roll, but I got mired up and haven't submitted it again. I'll try to do so today.

Phil
Previous: Junio C HamanoNext: Phil Hord
Message 3 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.