From: Enrico Scholz Date: Tue, 1 Feb 2005 02:06:06 +0000 (+0000) Subject: copyReg(): open out_fd with O_RDWR, fixed resource leak in error-case X-Git-Tag: IPSENTINEL_VERSION_0_12~156 X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=35f92ae82ef67ab372f8953346f11ea911e4e901;p=util-vserver.git copyReg(): open out_fd with O_RDWR, fixed resource leak in error-case git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@1838 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- diff --git a/util-vserver/lib_internal/unify-copy.c b/util-vserver/lib_internal/unify-copy.c index c67b48e..554c077 100644 --- a/util-vserver/lib_internal/unify-copy.c +++ b/util-vserver/lib_internal/unify-copy.c @@ -63,7 +63,7 @@ copyReg(char const *src, struct stat const *src_stat, char const *dst) { int in_fd = open(src, O_RDONLY|O_NOCTTY|O_NONBLOCK|O_NOFOLLOW|O_LARGEFILE); - int out_fd = in_fd==-1 ? -1 : open(dst, O_CREAT|O_EXCL, 0200); + int out_fd = in_fd==-1 ? -1 : open(dst, O_RDWR|O_CREAT|O_EXCL, 0200); bool res = false; if (in_fd==-1 || out_fd==-1 || @@ -74,7 +74,7 @@ copyReg(char const *src, struct stat const *src_stat, ssize_t l = read(in_fd, buf, sizeof buf); if (l==-1) goto err; if (l==0) break; - if (!WwriteAll(out_fd, buf, l, 0)) return false; + if (!WwriteAll(out_fd, buf, l, 0)) goto err; } res = true;