🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.git
1 messages
1 total messages Started by Junio C Hamano Tue, 24 Nov 2026 19:19
Re: [PATCH] filter-branch: check hex oids in state-branch map
#3727
Author: Junio C Hamano
Date: Tue, 24 Nov 2026 19:19
36 lines
14177 bytes
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.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads