]> git.ipfire.org Git - thirdparty/git.git/commit
builtin/bundle: abort "verify" early when there is no repository
authorPatrick Steinhardt <ps@pks.im>
Tue, 7 May 2024 04:53:24 +0000 (06:53 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 7 May 2024 05:50:49 +0000 (22:50 -0700)
commit332b56b7623c641dbf2f7712e338c0ca2dd423be
treea6c6e26ec0e3cd485ca0926f83d985fdff8a4bc0
parentce992ce29a2ebed8daa1f46e712ba38b79b53062
builtin/bundle: abort "verify" early when there is no repository

Verifying a bundle requires us to have a repository. This is encoded in
`verify_bundle()`, which will return an error if there is no repository.
We call `open_bundle()` before we call `verify_bundle()` though, which
already performs some verifications even though we may ultimately abort
due to a missing repository.

This is problematic because `open_bundle()` already reads the bundle
header and verifies that it contains a properly formatted hash. When
there is no repository we have no clue what hash function to expect
though, so we always end up assuming SHA1 here, which may or may not be
correct. Furthermore, we are about to stop initializing `the_hash_algo`
when there is no repository, which will lead to segfaults.

Check early on whether we have a repository to fix this issue.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/bundle.c