Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bundle: avoid closing file descriptor twice #1857

Open
wants to merge 1 commit into
base: maint-2.48
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion bundle.c
Original file line number Diff line number Diff line change
Expand Up @@ -607,8 +607,10 @@ int unbundle(struct repository *r, struct bundle_header *header,
if (!opts)
opts = &opts_fallback;

if (verify_bundle(r, header, opts->flags))
if (verify_bundle(r, header, opts->flags)) {
close(bundle_fd);
return -1;
}

strvec_pushl(&ip.args, "index-pack", "--fix-thin", "--stdin", NULL);

Expand Down
2 changes: 2 additions & 0 deletions bundle.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ struct unbundle_opts {
*
* Before unbundling, this method will call verify_bundle() with 'flags'
* provided in 'opts'.
*
* Note that the `bundle_fd` will be closed as part of the operation.
*/
int unbundle(struct repository *r, struct bundle_header *header,
int bundle_fd, struct strvec *extra_index_pack_args,
Expand Down
1 change: 1 addition & 0 deletions transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ static int fetch_refs_from_bundle(struct transport *transport,

ret = unbundle(the_repository, &data->header, data->fd,
&extra_index_pack_args, &opts);
data->fd = -1; /* `unbundle()` closes the file descriptor */
transport->hash_algo = data->header.hash_algo;

strvec_clear(&extra_index_pack_args);
Expand Down
Loading