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

Re: [msysGit] Re: [PATCH] mingw: do not crash on open(NULL, ...)

From
Erik Faye-Lund <kusmabite@gmail.com>
Date
Sep 23, 2010, 21:06 UTC
Message-ID
<AANLkTinW=1M81X4-7iqVXX0gKoAW8Rvvt+A7zkoQBnN8@mail.gmail.com>
In-Reply-To
<AANLkTimviqUqcy40aR=DC--tqKHWXfX9gLMoX7tyjafe@mail.gmail.com>
On Thu, Sep 23, 2010 at 1:27 PM, Pat Thoyts <patthoyts@gmail.com> wrote:
> (Apparently gmail on a phone insists on top posting)
Fixed ;)
Show 24 quoted lines
> On 23 Sep 2010 19:00, "Erik Faye-Lund" <kusmabite@gmail.com> wrote:
>> On Thu, Sep 23, 2010 at 10:35 AM, Erik Faye-Lund <kusmabite@gmail.com>
>> wrote:
>>> Since open() already sets errno correctly for the NULL-case, let's just
>>> avoid the problematic strcmp.
>>>
>>> Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
>>
>> I guess I should add a comment as to why this patch is needed:
>>
>> This seems to be the culprit for issue 523 in the msysGit issue
>> tracker: http://code.google.com/p/msysgit/issues/detail?id=523
>>
>> fetch_and_setup_pack_index() apparently pass a NULL-pointer to
>> parse_pack_index(), which in turn pass it to check_packed_git_idx(),
>> which again pass it to open(). This all looks intentional to my
>> (http.c-untrained) eye.
>>
>> The code in mingw_open was introduced in commit 3e4a1ba (by Johannes
>> Sixt), and the lack of a NULL-check looks like a simple oversight.
>
> It looks like this problem was missed by the test suite. Any chance of a
> test as well? Got to catch those regressions.
>

I don't think it's practical to test CRT functions directly, but perhaps a test for parse_pack_index() or some level above that might make sense. I tried looking at the this has been done for sha1_file previously, but it seems there's not really any tests at this level. And all tests for http.c seems to depend on Apache being installed (something we do not have in msysGit), so adding a test at this level wouldn't have helped us any...

In other words, I don't think there is any natural point to add a test for this. Feel free to make suggestions, though.

Previous: Pat ThoytsNext: Junio C Hamano
Message 4 of 12 in “mingw: do not crash on open(NULL, ...)”
  1. mingw: do not crash on open(NULL, ...)Erik Faye-Lund, Sep 23, 2010
  2. Erik Faye-LundSep 23, 2010
  3. Pat ThoytsSep 23, 2010
  4. Erik Faye-LundSep 23, 2010
  5. Junio C HamanoSep 23, 2010
  6. Erik Faye-LundSep 27, 2010
  7. Pat ThoytsSep 27, 2010
  8. Erik Faye-LundSep 27, 2010
  9. Johannes SchindelinSep 27, 2010
  10. Johannes SchindelinSep 24, 2010
  11. Johannes SixtSep 23, 2010
  12. Pat ThoytsSep 24, 2010

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.