Skip to content

Commit b75530a

Browse files
committed
Merge branch 'of/bundle-uninitialized-memory-fix' into seen
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
2 parents 6fa5be4 + cc7510f commit b75530a

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

‎bundle.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ int create_bundle(struct repository *r, const char *path,
492492
int bundle_fd = -1;
493493
int bundle_to_stdout;
494494
int ref_count = 0;
495-
struct rev_info revs, revs_copy;
495+
struct rev_info revs, revs_copy = { 0 };
496496
int min_version = 2;
497497
struct bundle_prerequisites_info bpi;
498498
int ret;

‎t/t5607-clone-bundle.sh‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,13 @@ test_expect_success 'failed bundle creation does not leave cruft' '
127127
test_path_is_missing fail.bundle.lock
128128
'
129129

130+
test_expect_success 'an unknown argument after the revisions is an error' '
131+
test_must_fail git bundle create unknown.bundle main --no-such-option \
132+
2>err &&
133+
test_grep "unrecognized argument: --no-such-option" err &&
134+
test_path_is_missing unknown.bundle
135+
'
136+
130137
test_expect_success 'fetch SHA-1 from bundle' '
131138
test_create_repo foo &&
132139
test_commit -C foo x &&

0 commit comments

Comments
 (0)