@@ -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);
From: Tedd Ho-Jeong An <tedd.an@intel.com> This patch fixes the unchecked return value(CWE-252) issues reported by the Coverity. --- plugins/admin.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)