Re: [PATCHv2 3/4] bundle: don't leak an fd in case of early return

2016-04-01 Thread Philip Oakley
From: "Stefan Beller" On Thu, Mar 31, 2016 at 12:00 PM, Philip Oakley wrote: From: "Stefan Beller" In successful operation `write_pack_data` will close the `bundle_fd`, but when we exit early, we need to take care of the file

Re: [PATCHv2 3/4] bundle: don't leak an fd in case of early return

2016-03-31 Thread Stefan Beller
On Thu, Mar 31, 2016 at 12:00 PM, Philip Oakley wrote: > From: "Stefan Beller" >> >> In successful operation `write_pack_data` will close the `bundle_fd`, >> but when we exit early, we need to take care of the file descriptor >> as well as the lock file

Re: [PATCHv2 3/4] bundle: don't leak an fd in case of early return

2016-03-31 Thread Philip Oakley
From: "Stefan Beller" In successful operation `write_pack_data` will close the `bundle_fd`, but when we exit early, we need to take care of the file descriptor as well as the lock file ourselves. The lock file may be deleted at the end of running the program, but we are in

Re: [PATCHv2 3/4] bundle: don't leak an fd in case of early return

2016-03-31 Thread Stefan Beller
On Wed, Mar 30, 2016 at 10:41 AM, Eric Sunshine wrote: >> - else if (ref_count < 0) >> - return -1; >> + else if (ref_count < 0) { >> + if (!bundle_to_stdout) >> + close(bundle_fd); > > Why is this close() here

Re: [PATCHv2 3/4] bundle: don't leak an fd in case of early return

2016-03-30 Thread Eric Sunshine
On Wed, Mar 30, 2016 at 1:05 PM, Stefan Beller wrote: > In successful operation `write_pack_data` will close the `bundle_fd`, > but when we exit early, we need to take care of the file descriptor > as well as the lock file ourselves. The lock file may be deleted at the > end

Re: [PATCHv2 3/4] bundle: don't leak an fd in case of early return

2016-03-30 Thread Jeff King
On Wed, Mar 30, 2016 at 10:05:17AM -0700, Stefan Beller wrote: > diff --git a/bundle.c b/bundle.c > index 506ac49..fbc8593 100644 > --- a/bundle.c > +++ b/bundle.c > @@ -407,6 +407,7 @@ int create_bundle(struct bundle_header *header, const > char *path, > int bundle_to_stdout; > int

[PATCHv2 3/4] bundle: don't leak an fd in case of early return

2016-03-30 Thread Stefan Beller
In successful operation `write_pack_data` will close the `bundle_fd`, but when we exit early, we need to take care of the file descriptor as well as the lock file ourselves. The lock file may be deleted at the end of running the program, but we are in library code, so we should not rely on that.