Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Dominik Maier <dmnk@google.com>
Cc: git@vger.kernel.org,  Grant Moyer <dev@grantmoyer.com>,
	 Michele Locati <michele@locati.it>,
	 Patrick Steinhardt <ps@pks.im>,
	dmnk+artist@google.com
Subject: Re: [PATCH] filter-branch: check hex oids in state-branch map
Date: Tue, 24 Nov 2026 11:19:00 -0800	[thread overview]
Message-ID: <xmqqmrqyqbq3.fsf@gitster.g> (raw)
In-Reply-To: <20261119192316.2688525-1-dmnk@google.com> (Dominik Maier's message of "Thu, 19 Nov 2026 20:23:16 +0100")

Dominik Maier <dmnk@google.com> writes:

> When "--state-branch" loads an existing "filter.map" blob,
> git-filter-branch splits each "from:to" line (restored to "from:to"
> order in 4811dabed7 (filter-branch: fix commit map init from state
> branch, 2026-10-02)) and writes "../map/$from_commit" without checking
> that "$from_commit" or "$to_commit" contains valid hexadecimal object
> IDs.
>
> A malformed or untrusted state branch whose "filter.map" contains empty
> keys, slashes, backslashes, or ".." segments writes outside
> "$tempdir/map" instead of failing cleanly.

Nice catch.  With an empty key like ":foo", redirection to "../map/"
fails with an "Is a directory" error inside the loop without calling
die(), and keys containing "../" can escape "$tempdir/map" into the
surrounding working tree.

> Read lines with "IFS= read -r line", and require "$from_commit" to be
> non-empty lowercase hex and "$to_commit" to contain only lowercase hex
> digits and spaces (allowing empty "$to_commit" for pruned commits)
> before writing "../map/$from_commit".

Mentioning that $to_commit can be empty and the reason why is good.  It
might help future readers to briefly mention why spaces are allowed in
$to_commit as well.  I presume that it is because a single 'from' can be
mapped to more than one commits, and the map() function that dumps the
contents of ../map/$from_commit file is expected to be used like

    for reparent in $(map "$parent"); do ... use each $reparent ...; done

without dq around $(map) call, to replace $parent (a from commit) with
these commits in the $to_commit SP delimited list?

Looks good.  Thanks.

  reply	other threads:[~2026-11-24 19:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 19:23 [PATCH] filter-branch: check hex oids in state-branch map Dominik Maier
2026-11-24 19:19 ` Junio C Hamano [this message]
2026-11-30 16:22   ` [PATCH v2] " Dominik Maier

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=xmqqmrqyqbq3.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=dev@grantmoyer.com \
    --cc=dmnk+artist@google.com \
    --cc=dmnk@google.com \
    --cc=git@vger.kernel.org \
    --cc=michele@locati.it \
    --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