Merge branch 'of/bundle-uninitialized-memory-fix'

The 'git bundle create' command has been updated to initialize the
revs_copy structure at declaration. This prevents a potential crash
caused by reading uninitialized stack memory during cleanup when an
unrecognized argument is provided.

* of/bundle-uninitialized-memory-fix:
  bundle: do not free uninitialized memory on bad arguments
This commit is contained in:
Junio C Hamano committed 2026-10-29 07:18:00 -07:00
commit 3a5cd30544
2 files changed
+8 -1

No files matched your search

+1 -1
View File
@@ -492,7 +492,7 @@ int create_bundle(struct repository *r, const char *path,
int bundle_fd = -1;
int bundle_to_stdout;
int ref_count = 0;
struct rev_info revs, revs_copy;
struct rev_info revs, revs_copy = { 0 };
int min_version = 2;
struct bundle_prerequisites_info bpi;
int ret;
+7
View File
@@ -127,6 +127,13 @@ test_expect_success 'failed bundle creation does not leave cruft' '
test_path_is_missing fail.bundle.lock
'
test_expect_success 'an unknown argument after the revisions is an error' '
test_must_fail git bundle create unknown.bundle main --no-such-option \
2>err &&
test_grep "unrecognized argument: --no-such-option" err &&
test_path_is_missing unknown.bundle
'
test_expect_success 'fetch SHA-1 from bundle' '
test_create_repo foo &&
test_commit -C foo x &&