return victim_key;
}
-static void __insert_hash(GHashTable *hash, const char *key,
+static struct datacontrol_cert_info* __insert_hash(GHashTable *hash, const char *key,
bool is_map, cert_status_type status)
{
struct datacontrol_cert_info *cert_info;
sizeof(struct datacontrol_cert_info));
if (cert_info == NULL) {
_LOGE("out of memory.");
- return;
+ return NULL;
}
if (is_map)
if (hash_key == NULL) {
free(cert_info);
_LOGE("out of memory.");
- return;
+ return NULL;
}
g_hash_table_insert(hash, hash_key, cert_info);
+ return cert_info;
}
static void __free_cb_info(gpointer data)
{
int ret;
bool is_trusted;
- bool is_update = false;
char *provider_appid;
char appid[255];
GHashTable *hash_table;
return DATA_CONTROL_ERROR_NONE;
else if (*status == CERT_MISMATCH)
return DATA_CONTROL_ERROR_PERMISSION_DENIED;
-
- is_update = true;
+ } else {
+ cert_info = __insert_hash(hash_table, provider_id, is_map, CERT_UNCHECKED);
+ if (cert_info == NULL) {
+ return DATA_CONTROL_ERROR_OUT_OF_MEMORY;
+ }
+ status = is_map ? &cert_info->map : &cert_info->sql;
}
ret = pkgmgrinfo_appinfo_usr_get_datacontrol_trusted_info(provider_id,
}
if (!is_trusted) {
- if (is_update)
- *status = CERT_MATCH;
- else
- __insert_hash(hash_table, provider_id, is_map, CERT_MATCH);
+ *status = CERT_MATCH;
free(provider_appid);
return DATA_CONTROL_ERROR_NONE;
}
if (res != PMINFO_CERT_COMPARE_MATCH) {
_LOGE("certificate mismatch. provider : %s consumer %s",
provider_appid, consumer_appid);
- if (is_update)
- *status = CERT_MISMATCH;
- else
- __insert_hash(hash_table, provider_id, is_map, CERT_MISMATCH);
+ *status = CERT_MISMATCH;
free(provider_appid);
return DATA_CONTROL_ERROR_PERMISSION_DENIED;
}
- if (is_update)
- *status = CERT_MATCH;
- else
- __insert_hash(hash_table, provider_id, is_map, CERT_MATCH);
-
+ *status = CERT_MATCH;
free(provider_appid);
return DATA_CONTROL_ERROR_NONE;