2021-09-29 15:58:15 +00:00
|
|
|
From 05bc0fe72b53476a9d4da3957c6d6cba00c76eea Mon Sep 17 00:00:00 2001
|
2020-10-15 15:31:21 +00:00
|
|
|
From: Petr Lautrbach <plautrba@redhat.com>
|
|
|
|
Date: Wed, 7 Nov 2018 18:17:34 +0100
|
|
|
|
Subject: [PATCH] libsemanage: Fix RESOURCE_LEAK and USE_AFTER_FREE coverity
|
|
|
|
scan defects
|
|
|
|
|
|
|
|
---
|
|
|
|
libsemanage/src/direct_api.c | 21 ++++++++-------------
|
|
|
|
1 file changed, 8 insertions(+), 13 deletions(-)
|
|
|
|
|
|
|
|
diff --git a/libsemanage/src/direct_api.c b/libsemanage/src/direct_api.c
|
2021-09-29 15:58:15 +00:00
|
|
|
index f0e2300a2f58..b7a3e0f17cc1 100644
|
2020-10-15 15:31:21 +00:00
|
|
|
--- a/libsemanage/src/direct_api.c
|
|
|
|
+++ b/libsemanage/src/direct_api.c
|
2021-09-29 15:58:15 +00:00
|
|
|
@@ -1029,7 +1029,7 @@ static int semanage_direct_write_langext(semanage_handle_t *sh,
|
2020-10-15 15:31:21 +00:00
|
|
|
|
|
|
|
fp = NULL;
|
|
|
|
|
|
|
|
- ret = 0;
|
|
|
|
+ return 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (fp != NULL) fclose(fp);
|
2021-09-29 15:58:15 +00:00
|
|
|
@@ -2186,7 +2186,6 @@ cleanup:
|
2020-10-15 15:31:21 +00:00
|
|
|
semanage_module_info_destroy(sh, modinfo);
|
|
|
|
free(modinfo);
|
|
|
|
|
|
|
|
- if (fp != NULL) fclose(fp);
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2021-09-29 15:58:15 +00:00
|
|
|
@@ -2351,16 +2350,6 @@ static int semanage_direct_get_module_info(semanage_handle_t *sh,
|
2020-10-15 15:31:21 +00:00
|
|
|
free(tmp);
|
|
|
|
tmp = NULL;
|
|
|
|
|
|
|
|
- if (fclose(fp) != 0) {
|
|
|
|
- ERR(sh,
|
|
|
|
- "Unable to close %s module lang ext file.",
|
|
|
|
- (*modinfo)->name);
|
|
|
|
- status = -1;
|
|
|
|
- goto cleanup;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- fp = NULL;
|
|
|
|
-
|
|
|
|
/* lookup enabled/disabled status */
|
|
|
|
ret = semanage_module_get_path(sh,
|
|
|
|
*modinfo,
|
2021-09-29 15:58:15 +00:00
|
|
|
@@ -2404,7 +2393,13 @@ cleanup:
|
2020-10-15 15:31:21 +00:00
|
|
|
free(modinfos);
|
|
|
|
}
|
|
|
|
|
|
|
|
- if (fp != NULL) fclose(fp);
|
|
|
|
+ if (fp != NULL && fclose(fp) != 0) {
|
|
|
|
+ ERR(sh,
|
|
|
|
+ "Unable to close %s module lang ext file.",
|
|
|
|
+ (*modinfo)->name);
|
|
|
|
+ status = -1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
--
|
2021-07-28 15:23:05 +00:00
|
|
|
2.32.0
|
2020-10-15 15:31:21 +00:00
|
|
|
|