Without this change, dpkg-divert might write
cannot rename 'src' to 'dest': Success
because close-ing the src file descriptor to clean up can clobber
errno after creat has failed. (This probably does not happen with
glibc unless the "close" fails, but it seems best to be safe.)
Signed-off-by: Jonathan Nieder <[email protected]>
---
Hi,
Raphaël Hertzog wrote:
> --- a/src/divertcmd.c
> +++ b/src/divertcmd.c
> @@ -216,8 +216,10 @@ file_copy(const char *src, const char *dst)
> return -1;
>
> dstfd = creat(dst, 0600);
> - if (dstfd < 0)
> + if (dstfd < 0) {
> + close(srcfd);
> return -1;
> + }
Good catch. One small nitpick.
src/divertcmd.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/src/divertcmd.c b/src/divertcmd.c
index e01ece0..def2071 100644
--- a/src/divertcmd.c
+++ b/src/divertcmd.c
@@ -217,7 +217,9 @@ file_copy(const char *src, const char *dst)
dstfd = creat(dst, 0600);
if (dstfd < 0) {
+ int e = errno;
close(srcfd);
+ errno = e;
return -1;
}
--
1.7.5.rc0
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]