--- Begin Message ---
Subject: |
[PATCH] sync: add missing brackets in sync_arg() |
Date: |
Tue, 6 Nov 2018 13:02:24 +0100 |
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
--- End Message ---
--- Begin Message ---
Subject: |
Re: bug#33287: [PATCH] sync: add missing brackets in sync_arg() |
Date: |
Tue, 6 Nov 2018 10:35:58 -0800 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 |
Thanks, I installed that and am closing the bug report.
--- End Message ---