summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorTedd Ho-Jeong An <tedd.an@intel.com>2021-10-18 10:28:28 -0700
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2021-10-18 15:31:54 -0700
commit0b23a290d097e3b85ec13d4c11357316c6b26225 (patch)
treeeba5de049d91d03440e37ec31611c57d4dd09f7f /plugins
parent1dbc27ec331132b422e20ea317d652e4275fc445 (diff)
downloadbluez-0b23a290d097e3b85ec13d4c11357316c6b26225.tar.gz
plugins/admin: Fix unchecked return value
This patch fixes the unchecked return value(CWE-252) issues reported by the Coverity.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/admin.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/plugins/admin.c b/plugins/admin.c
index 7b7190a06..a8e7d2cd7 100644
--- a/plugins/admin.c
+++ b/plugins/admin.c
@@ -247,6 +247,7 @@ failed:
static void store_policy_settings(struct btd_admin_policy *admin_policy)
{
GKeyFile *key_file = NULL;
+ GError *gerr = NULL;
char *filename = ADMIN_POLICY_STORAGE;
char *key_file_data = NULL;
char **uuid_strs = NULL;
@@ -274,7 +275,12 @@ static void store_policy_settings(struct btd_admin_policy *admin_policy)
}
key_file_data = g_key_file_to_data(key_file, &length, NULL);
- g_file_set_contents(ADMIN_POLICY_STORAGE, key_file_data, length, NULL);
+ if (!g_file_set_contents(ADMIN_POLICY_STORAGE, key_file_data, length,
+ &gerr)) {
+ error("Unable set contents for %s: (%s)", ADMIN_POLICY_STORAGE,
+ gerr->message);
+ g_error_free(gerr);
+ }
g_free(key_file_data);
free_uuid_strings(uuid_strs, num_uuids);
@@ -335,6 +341,7 @@ failed:
static void load_policy_settings(struct btd_admin_policy *admin_policy)
{
GKeyFile *key_file;
+ GError *gerr = NULL;
char *filename = ADMIN_POLICY_STORAGE;
struct stat st;
@@ -343,7 +350,11 @@ static void load_policy_settings(struct btd_admin_policy *admin_policy)
key_file = g_key_file_new();
- g_key_file_load_from_file(key_file, filename, 0, NULL);
+ if (!g_key_file_load_from_file(key_file, filename, 0, &gerr)) {
+ error("Unable to load key file from %s: (%s)", filename,
+ gerr->message);
+ g_error_free(gerr);
+ }
key_file_load_service_allowlist(key_file, admin_policy);