From: Erik Faye-Lund <kusmabite@gmail.com>
To: Pat Thoyts <patthoyts@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>,
msysgit@googlegroups.com, git@vger.kernel.org,
"Shawn O. Pearce" <spearce@spearce.org>
Subject: Re: Re: [PATCH] mingw: do not crash on open(NULL, ...)
Date: Mon, 27 Sep 2010 15:37:16 +0200 [thread overview]
Message-ID: <AANLkTik5mr7MTPzrWPG00T40a08oiV7X8ZXBHkXva+DO@mail.gmail.com> (raw)
In-Reply-To: <AANLkTikv8M8xuESQzO7qfPB72d51hTcosUgKreLu7Y=C@mail.gmail.com>
On Mon, Sep 27, 2010 at 3:31 PM, Pat Thoyts <patthoyts@gmail.com> wrote:
> On 27 September 2010 14:19, Erik Faye-Lund <kusmabite@gmail.com> wrote:
>> On Fri, Sep 24, 2010 at 12:50 AM, Junio C Hamano <gitster@pobox.com> wrote:
>>> Erik Faye-Lund <kusmabite@gmail.com> writes:
>>>
>>>> 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.
>>>
>>> Surely, open(NULL) should be rejected by a sane system, and your patch
>>> looks sane to me.
>>>
>>
>> Since this doesn't seem to be in git.git yet, perhaps you could squash
>> this on top? I didn't notice it in time, but fopen lacked the same
>> check (freopen already had the check). It's not as important, because
>> it doesn't seem like we have any code reaching this path so far, but
>> it would IMO be better to fix this now rather than having to chase
>> down the issue again later...
>>
>> diff --git a/compat/mingw.c b/compat/mingw.c
>> index 4595aaa..f069fea 100644
>> --- a/compat/mingw.c
>> +++ b/compat/mingw.c
>> @@ -160,7 +160,7 @@ ssize_t mingw_write(int fd, const void *buf, size_t count)
>> #undef fopen
>> FILE *mingw_fopen (const char *filename, const char *otype)
>> {
>> - if (!strcmp(filename, "/dev/null"))
>> + if (filename && !strcmp(filename, "/dev/null"))
>> filename = "nul";
>> return fopen(filename, otype);
>> }
>>
>
> I'll apply this to the devel branch and try to remember to squash it
> on the next rebase-merge.
> Cheers,
> Pat
>
Wouldn't it be better to just get this squashed in git.git, and drop
the patch in the next rebase-merge? Since this bug is in git.git as
well, it makes sense to get the patch merged there, no?
next prev parent reply other threads:[~2010-09-27 13:38 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-23 17:35 [PATCH] mingw: do not crash on open(NULL, ...) Erik Faye-Lund
2010-09-23 17:59 ` Erik Faye-Lund
2010-09-23 20:27 ` Pat Thoyts
2010-09-23 21:06 ` [msysGit] " Erik Faye-Lund
2010-09-23 22:50 ` Junio C Hamano
2010-09-27 13:19 ` Erik Faye-Lund
2010-09-27 13:31 ` [msysGit] " Pat Thoyts
2010-09-27 13:37 ` Erik Faye-Lund [this message]
2010-09-27 13:59 ` Johannes Schindelin
2010-09-24 0:32 ` [msysGit] " Johannes Schindelin
2010-09-23 20:08 ` [msysGit] " Johannes Sixt
2010-09-24 14:22 ` Pat Thoyts
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AANLkTik5mr7MTPzrWPG00T40a08oiV7X8ZXBHkXva+DO@mail.gmail.com \
--to=kusmabite@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=msysgit@googlegroups.com \
--cc=patthoyts@gmail.com \
--cc=spearce@spearce.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).