* [PATCH] copy_fd: close ifd on error
@ 2005-12-27 8:19 Sam Ravnborg
2005-12-27 9:02 ` Junio C Hamano
0 siblings, 1 reply; 2+ messages in thread
From: Sam Ravnborg @ 2005-12-27 8:19 UTC (permalink / raw)
To: git
In copy_fd when write fails we ought to close input file descriptor.
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
---
Found while looking at the source for inspiration for something else.
I did not see any error related to this.
Sam
diff --git a/copy.c b/copy.c
index 7100eed..08a3d38 100644
--- a/copy.c
+++ b/copy.c
@@ -22,11 +22,14 @@ int copy_fd(int ifd, int ofd)
buf += written;
len -= written;
}
- else if (!written)
+ else if (!written) {
+ close(ifd);
return error("copy-fd: write returned 0");
- else
+ } else {
+ close(ifd);
return error("copy-fd: write returned %s",
strerror(errno));
+ }
}
}
close(ifd);
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] copy_fd: close ifd on error
2005-12-27 8:19 [PATCH] copy_fd: close ifd on error Sam Ravnborg
@ 2005-12-27 9:02 ` Junio C Hamano
0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2005-12-27 9:02 UTC (permalink / raw)
To: Sam Ravnborg; +Cc: git
Sam Ravnborg <sam@ravnborg.org> writes:
> In copy_fd when write fails we ought to close input file descriptor.
>
> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
> ---
>
> Found while looking at the source for inspiration for something else.
> I did not see any error related to this.
Thanks. I think the only place this matters is git-local-fetch
which nobody uses these days where it can leak handful ifd.
All other users immediately exit upon seeing failure return from
the function.
Of course this would matter much when we do libification.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-12-27 9:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-27 8:19 [PATCH] copy_fd: close ifd on error Sam Ravnborg
2005-12-27 9:02 ` Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).