Subject: bug#33287: closed (Re: bug#33287: [PATCH] sync: add missing brackets in sync_arg())

From: [email-masked] (GNU bug Tracking System)
Date: Tue, 06 Nov 2018 18:37:02 +0000

Your bug report

#33287: [PATCH] sync: add missing brackets in sync_arg()

which was filed against the coreutils package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
33287: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=33287
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#33287: [PATCH] sync: add missing brackets in sync_arg()
From: Paul Eggert <[email-masked]>
To: Kamil Dudka <[email-masked]>, [email-masked]
Date: Tue, 6 Nov 2018 10:35:58 -0800
List-Id: <debbugs-submit.debbugs.gnu.org>

Thanks, I installed that and am closing the bug report.

Subject: [PATCH] sync: add missing brackets in sync_arg()
From: Kamil Dudka <[email-masked]>
To: [email-masked]
Date: Tue, 6 Nov 2018 13:02:24 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Detected by Coverity Analysis:

Error: RESOURCE_LEAK (CWE-772):
coreutils-8.30/src/sync.c:112: open_fn: Returning handle opened by "open".
coreutils-8.30/src/sync.c:112: var_assign: Assigning: "fd" = handle returned from "open(file, 2049)".
coreutils-8.30/src/sync.c:115: leaked_handle: Handle variable "fd" going out of scope leaks the handle.
113|         if (fd < 0)
114|           error (0, rd_errno, _("error opening %s"), quoteaf (file));
115|->       return false;
116|       }
117|
---
 src/sync.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/sync.c b/src/sync.c
index bd3671a19..607fa8f7f 100644
--- a/src/sync.c
+++ b/src/sync.c
@@ -111,8 +111,10 @@ sync_arg (enum sync_mode mode, char const *file)
       if (open_flags != (O_WRONLY | O_NONBLOCK))
         fd = open (file, O_WRONLY | O_NONBLOCK);
       if (fd < 0)
-        error (0, rd_errno, _("error opening %s"), quoteaf (file));
-      return false;
+        {
+          error (0, rd_errno, _("error opening %s"), quoteaf (file));
+          return false;
+        }
     }
 
   /* We used O_NONBLOCK above to not hang with fifos,
-- 
2.17.2