{
int ret;
void *context;
- void *malware;
+ void *malware = NULL;
void *lib_handle;
int (*_csr_cs_context_create)(void **handle);
int (*_csr_cs_scan_file)(void *handle, const char *file_path, void **malware);
if (!_csr_cs_context_create || !_csr_cs_scan_file ||
!_csr_cs_context_destroy) {
ERR("Failed to load CSR symbols");
- ret = -1;
- goto catch;
+ dlclose(lib_handle);
+ return -1;
}
ret = _csr_cs_context_create(&context);
if (ret != 0) {
ERR("Failed to create context");
- ret = -1;
- goto catch;
+ dlclose(lib_handle);
+ return -1;
}
ret = _csr_cs_scan_file(context, path, &malware);
- if (ret != 0) {
+ /* the csr engine may not exist */
+ if (ret != 0)
DBG("CSR result[%d]", ret);
- ret = 0;
- goto catch;
- }
ret = _csr_cs_context_destroy(context);
- if (ret != 0) {
+ if (ret != 0)
ERR("Failed to destroy context");
- ret = -1;
- goto catch;
- }
+
+ dlclose(lib_handle);
if (malware != NULL) {
- ERR("CSR denied[%d] installation", path);
- ret = -1;
+ ERR("CSR detected malware from [%s]", path);
+ return -1;
+ } else {
+ return 0;
}
-
-catch:
- if (lib_handle)
- dlclose(lib_handle);
-
- return ret;
}
static int __kill_app(char *appid, uid_t uid)
ret = aul_terminate_pid_for_uid(pid, uid);
if (ret != AUL_R_OK) {
- ERR("failed to terminate app(%d)", appid);
+ ERR("failed to terminate app(%s)", appid);
return -1;
}
goto error;
}
+ job->extra_data = extra_getsize_info;
extra_getsize_info->getsize_fifo = strdup(fifo_path);
if (!extra_getsize_info->getsize_fifo) {
ERR("out of memory");
ERR("failed to mkfifo");
goto error;
}
- job->extra_data = extra_getsize_info;
snprintf(args, sizeof(args), "%s %s %s %d -k %s -u %d --sync",
backend_cmd, job->pkgid, job->args, job->caller_uid,
static int __process_set_app_icon(struct backend_job *job)
{
int ret;
+ pkgmgrinfo_appinfo_h handle = NULL;
+ char *app_root_path = NULL;
+ ret = pkgmgrinfo_appinfo_get_usr_appinfo(job->pkgid, job->target_uid, &handle);
+ if (ret != PMINFO_R_OK) {
+ _return_value_to_caller(job->req_id, g_variant_new("(i)", ret));
+ return PKGMGR_R_ENOPKG;
+ }
+
+ ret = pkgmgrinfo_appinfo_get_root_path(handle, &app_root_path);
+ if (ret != PMINFO_R_OK || !app_root_path) {
+ _return_value_to_caller(job->req_id, g_variant_new("(i)", ret));
+ pkgmgrinfo_appinfo_destroy_appinfo(handle);
+ return PKGMGR_R_ESYSTEM;
+ }
+
+ if (strncasecmp(job->args, app_root_path, strlen(app_root_path)) != 0 ||
+ strstr(job->args, "..") != NULL ||
+ access(job->args, F_OK) != 0) {
+ ERR("invalid path[%s]", job->args);
+ _return_value_to_caller(job->req_id, g_variant_new("(i)", ret));
+ pkgmgrinfo_appinfo_destroy_appinfo(handle);
+ return PKGMGR_R_EINVAL;
+ }
+
+ pkgmgrinfo_appinfo_destroy_appinfo(handle);
ret = pkgmgr_parser_update_app_icon_info_in_usr_db(job->pkgid,
job->target_uid, job->args);
_return_value_to_caller(job->req_id, g_variant_new("(i)", ret));