From: "René Scharfe" <l.s.r@web.de>
To: "D. Ben Knoble" <ben.knoble@gmail.com>,
Yuvraj Singh Chauhan <ysinghcin@gmail.com>
Cc: git@vger.kernel.org, christian.couder@gmail.com, stolee@gmail.com
Subject: Re: [PATCH v1] path-walk: fix NULL pointer dereference in error message
Date: Fri, 20 Mar 2026 19:54:21 +0100 [thread overview]
Message-ID: <98833ee0-4d63-4d72-9a0c-d668a421ece4@web.de> (raw)
In-Reply-To: <CALnO6CDnwYaAPhp67kaYWtV48ULjWAR6ks1khVXmSs1oWUbRDQ@mail.gmail.com>
On 3/20/26 4:16 PM, D. Ben Knoble wrote:
>
> When we compute "child" in either preceding branch using lookup_tree
> or lookup_blob, we only return NULL if !quiet in the object_as_type
> calls (assuming we hit the "else" case there, anyway). But quiet==0 in
> both callers along this path, so !quiet will be truthy and we'll
> error() out there instead, never returning to add_tree_entries.
error() just prints a message, it doesn't end the program.
> Since I didn't quickly come up with a reproduction, I can't quite
> prove this, anyway. It's also possible my analysis is based on code
> that has since changed (I happened to have a537e3e6e9 (Merge branch
> 'sp/send-email-validate-charset' into next, 2026-03-06) checked out at
> the moment).
We could build a tree referencing an object using a mismatched
type to hit that. It's possible by removing the type check from
builtin/mktree.c:mktree_line(), then using the resulting twisted tool:
$ commit=$(git rev-parse HEAD)
$ tree=$(printf "100644 blob $commit\tcommit\n" | git_evil mktree)
> Still, fixing such obviously wrong dereference is good, but I wonder
> if we should go further?
>
> You mentioned git-backfill with a tree missing from the local odb; do
> you have a short reproduction script or test-case?
I don't know about backfill, but this would work:
$ echo $tree | git pack-objects --path-walk --all foo
René
next prev parent reply other threads:[~2026-03-20 18:54 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-20 11:48 [PATCH v1] path-walk: fix NULL pointer dereference in error message Yuvraj Singh Chauhan
2026-03-20 15:16 ` D. Ben Knoble
2026-03-20 16:14 ` Derrick Stolee
2026-03-23 9:45 ` Yuvraj Singh Chauhan
2026-03-20 17:08 ` Junio C Hamano
2026-03-20 18:54 ` René Scharfe [this message]
2026-03-22 14:21 ` D. Ben Knoble
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=98833ee0-4d63-4d72-9a0c-d668a421ece4@web.de \
--to=l.s.r@web.de \
--cc=ben.knoble@gmail.com \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=stolee@gmail.com \
--cc=ysinghcin@gmail.com \
/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