From: Junio C Hamano <gitster@pobox.com>
To: Patrick Steinhardt <ps@pks.im>
Cc: emilylime via GitGitGadget <gitgitgadget@gmail.com>,
git@vger.kernel.org, emilylime <emilyyyylime+git@gmail.com>
Subject: Re: [PATCH] archive: error instead of triggering a segfault in `git archive --remote=""`
Date: Mon, 10 Mar 2025 08:59:55 -0700 [thread overview]
Message-ID: <xmqq7c4wanb8.fsf@gitster.g> (raw)
In-Reply-To: <Z86WtQ-3Rk9OSmn_@pks.im> (Patrick Steinhardt's message of "Mon, 10 Mar 2025 08:37:25 +0100")
Patrick Steinhardt <ps@pks.im> writes:
>> + if (remote && !remote[0]) {
>
> Okay, so this triggers in case the user passes "--remote ''"?
> I see that we ultimately pass the string to `remote_get()`, so does that
> function segfault? If so, can other callers of that function segfault in
> a similar way? In that case, we should probably address the issue deeper
> down in the call stack.
A good thing to point out. If remote_get() segfaults, that is a
grave bug. If remote_get() returns a NULL for such a non-existent
remote, the code should be able to cope with it, or you found a bug.
In short, I agree with you that this may merely be sweeping a
problem under a rug, not addressing a real problem.
run_remote_archiver() seems to run remote_get() and use the returned
value (which could be NULL, if you named a remote nickname that you
do not even have) without validating when it calls transport_get(),
so that is probably where the problem lies. If I were writing this
code path, I would probably make run_remote_archiver() take a pointer
to an instance of "struct remote", moving the call to remote_get()
to the caller's side, and deal with an error inside cmd_archive().
Thanks.
next prev parent reply other threads:[~2025-03-10 15:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-09 10:12 [PATCH] archive: error instead of triggering a segfault in `git archive --remote=""` emilylime via GitGitGadget
2025-03-10 7:37 ` Patrick Steinhardt
2025-03-10 15:59 ` Junio C Hamano [this message]
2025-03-10 11:25 ` Junio C Hamano
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=xmqq7c4wanb8.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=emilyyyylime+git@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=ps@pks.im \
/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).