return NULL;
new_element->value = malloc(sizeof(char) * (SMACK_LABEL_LEN + 1) );
- if (NULL == new_element->value)
+ if (NULL == new_element->value) {
+ free(new_element);
return NULL;
+ }
strncpy(new_element->value, value, SMACK_LABEL_LEN);
new_element->value[SMACK_LABEL_LEN] = '\0';
}
}
+ if (!app_id_tmp) {
+ C_LOGE("No group id found");
+ ret = PC_ERR_FILE_OPERATION;
+ goto out;
+ }
+
if (!strcmp(app_id, app_id_tmp)) {
unsigned *gids_realloc = realloc(*gids, sizeof(unsigned) * (*len + 1));
if (gids_realloc == NULL) {
ret = smack_accesses_new(&smack);
if (ret != PC_OPERATION_SUCCESS) {
C_LOGE("smack_accesses_new failed");
- goto out;
+ return ret;
}
// Reading labels of all installed anti viruses from "database"
ret = get_all_avs_ids(&smack_label_av_list, &smack_label_av_list_len);
- if (ret != PC_OPERATION_SUCCESS ) {
+ if (ret != PC_OPERATION_SUCCESS) {
C_LOGE("Error while geting data from database");
- goto out;
+ return ret;
}
// for each anti-virus put rule: "anti_virus_id app_id rwx"
C_LOGD("Enter function: %s", __func__);
int ret = PC_OPERATION_SUCCESS;
- char* smack_file = NULL;
- char* dac_file = NULL;
+ char* smack_file AUTO_FREE;
+ char* dac_file AUTO_FREE;
struct smack_accesses* accesses = NULL;
FILE* file = NULL;
// get feature SMACK file name
ret = perm_file_path(&smack_file, app_type, api_feature_name, ".smack");
- if (ret != PC_OPERATION_SUCCESS ) {
+ if (ret != PC_OPERATION_SUCCESS || !smack_file ) {
return ret;
}
if (list_of_db_gids && list_size > 0) {
// get feature DAC file name
ret = perm_file_path(&dac_file, app_type, api_feature_name, ".dac");
- if (ret != PC_OPERATION_SUCCESS ) {
+ if (ret != PC_OPERATION_SUCCESS || !dac_file ) {
return ret;
}