56 lines
1.5 KiB
Diff
56 lines
1.5 KiB
Diff
From c1a8da6e4a2b53ea346d4493346cde7c0a5a5f49 Mon Sep 17 00:00:00 2001
|
||
From: Petr Lautrbach <plautrba@redhat.com>
|
||
Date: Fri, 11 Mar 2022 12:53:30 +0100
|
||
Subject: [PATCH] libselinux: Close leaked FILEs
|
||
MIME-Version: 1.0
|
||
Content-Type: text/plain; charset=UTF-8
|
||
Content-Transfer-Encoding: 8bit
|
||
|
||
Fixes:
|
||
label_media.c:94:24: warning: leak of FILE ‘fopen (path_28, "re")’ [CWE-775] [-Wanalyzer-file-leak]
|
||
label_x.c:121:24: warning: leak of FILE ‘fopen (path_28, "re")’ [CWE-775] [-Wanalyzer-file-leak]
|
||
|
||
Signed-off-by: Petr Lautrbach <plautrba@redhat.com>
|
||
---
|
||
src/label_media.c | 4 ++--
|
||
src/label_x.c | 4 ++--
|
||
2 files changed, 4 insertions(+), 4 deletions(-)
|
||
|
||
diff --git a/src/label_media.c b/src/label_media.c
|
||
index eb27deaf..3137c18e 100644
|
||
--- a/src/label_media.c
|
||
+++ b/src/label_media.c
|
||
@@ -95,10 +95,10 @@ static int init(struct selabel_handle *rec, const struct selinux_opt *opts,
|
||
__fsetlocking(fp, FSETLOCKING_BYCALLER);
|
||
|
||
if (fstat(fileno(fp), &sb) < 0)
|
||
- return -1;
|
||
+ goto finish;
|
||
if (!S_ISREG(sb.st_mode)) {
|
||
errno = EINVAL;
|
||
- return -1;
|
||
+ goto finish;
|
||
}
|
||
rec->spec_file = strdup(path);
|
||
|
||
diff --git a/src/label_x.c b/src/label_x.c
|
||
index e9fa063f..e6e8d9f6 100644
|
||
--- a/src/label_x.c
|
||
+++ b/src/label_x.c
|
||
@@ -122,10 +122,10 @@ static int init(struct selabel_handle *rec, const struct selinux_opt *opts,
|
||
__fsetlocking(fp, FSETLOCKING_BYCALLER);
|
||
|
||
if (fstat(fileno(fp), &sb) < 0)
|
||
- return -1;
|
||
+ goto finish;
|
||
if (!S_ISREG(sb.st_mode)) {
|
||
errno = EINVAL;
|
||
- return -1;
|
||
+ goto finish;
|
||
}
|
||
rec->spec_file = strdup(path);
|
||
|
||
--
|
||
2.27.0
|
||
|