if (MEDIA_CONTENT_OTHER_SUPPORT == -1) {
ret = system_info_get_platform_bool("http://tizen.org/feature/content.scanning.others", &is_supported);
- if (ret != SYSTEM_INFO_ERROR_NONE) {
- content_debug("SYSTEM_INFO_ERROR: content.scanning.others [%d]", ret);
- return false;
- }
+ content_retvm_if(ret != SYSTEM_INFO_ERROR_NONE, false, "SYSTEM_INFO_ERROR: content.scanning.others [%d]", ret);
MEDIA_CONTENT_OTHER_SUPPORT = is_supported;
}
if (!MEDIA_CONTENT_OTHER_SUPPORT) {
ret = media_svc_get_media_type(path, &media_type);
content_retvm_if(ret != MS_MEDIA_ERR_NONE, false, "Failed to get media type");
-
- if (media_type == MEDIA_CONTENT_TYPE_OTHERS)
- return false;
+ content_retv_if(media_type == MEDIA_CONTENT_TYPE_OTHERS, false);
}
return true;
if (exist < 0) {
if (errno == EACCES || errno == EPERM) {
content_stderror("open file fail");
- content_sec_debug("path [%s]", path);
return MEDIA_CONTENT_ERROR_PERMISSION_DENIED;
} else {
content_stderror("open file fail");
- content_sec_debug("path [%s]", path);
return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
}
int _media_util_get_file_time(const char *path)
{
- struct stat statbuf;
- int ret = 0;
-
- memset(&statbuf, 0, sizeof(struct stat));
- ret = stat(path, &statbuf);
- if (ret == -1) {
- content_stderror("stat failed");
- return ret;
- }
+ struct stat statbuf = { 0, };
+
+ content_retvm_if(stat(path, &statbuf) == -1, 0, "stat failed");
return statbuf.st_mtime;
}
bool _media_util_is_ignorable_file(const char *path)
{
char *tmp_path = NULL;
- char *org_path = NULL;
+ g_autofree gchar *org_path = NULL;
#ifndef _USE_TVPD_MODE
char replace[MAX_PATH_LEN] = {0, };
content_retip_if_fail(STRING_VALID(path));
/* Check is exist (It may be the path to the deleted file) */
- if (!g_file_test(path, G_FILE_TEST_EXISTS)) {
- content_sec_debug("removed path[%s]", path);
- return false;
- }
+ content_retvm_if(!g_file_test(path, G_FILE_TEST_EXISTS), false, "removed path");
/* Check symbolic link file */
- if (g_file_test(path, G_FILE_TEST_IS_SYMLINK)) {
- content_error("symbolic link(file)");
- content_sec_debug("path : %s", path);
- return true;
- }
+ content_retvm_if(g_file_test(path, G_FILE_TEST_IS_SYMLINK), true, "symbolic link(file)");
/* Check hidden path */
- if (strstr(path, "/.") != NULL) {
- content_error("hidden path");
- content_sec_debug("path : %s", path);
- return true;
- }
+ content_retvm_if(strstr(path, "/."), true, "hidden path");
/* Check symbolic directory */
tmp_path = realpath(path, NULL);
#ifdef _USE_TVPD_MODE
if (g_strcmp0(tmp_path, org_path) != 0) {
content_error("symbolic link(directory)");
- content_sec_debug("path[%s] real[%s]", org_path, tmp_path);
SAFE_FREE(tmp_path);
- g_free(org_path);
return true;
}
#else
snprintf(replace, MAX_PATH_LEN, "%s%s", tzplatform_getenv(TZ_USER_MEDIASHARED), tmp_path + strlen(tzplatform_getenv(TZ_SYS_MEDIASHARED)));
if (g_strcmp0(replace, org_path) != 0) {
content_error("symbolic link(directory)");
- content_sec_debug("path[%s] real[%s]", org_path, tmp_path);
SAFE_FREE(tmp_path);
- g_free(org_path);
return true;
}
} else {
if (g_strcmp0(tmp_path, org_path) != 0) {
content_error("symbolic link(directory)");
- content_sec_debug("path[%s] real[%s]", org_path, tmp_path);
SAFE_FREE(tmp_path);
- g_free(org_path);
return true;
}
}
#endif
SAFE_FREE(tmp_path);
- g_free(org_path);
return false;
}
bool _media_util_is_ignorable_dir(const char *dir_path)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
-
if (!STRING_VALID(dir_path))
return true;
- content_sec_debug("dir_path : %s", dir_path);
-
/*1. Check Hidden Directory*/
- if (strstr(dir_path, "/.") != NULL) {
- content_error("hidden path");
- return true;
- }
+ content_retvm_if(strstr(dir_path, "/."), true, "hidden path");
/*2. Check Scan Ignore Directory*/
- if (!ms_user_is_valid_path(_content_get_uid(), dir_path)) {
- content_error("ms_user_is_valid_path failed : %d", ret);
- return true;
- }
+ content_retvm_if(!ms_user_is_valid_path(_content_get_uid(), dir_path), true, "ms_user_is_valid_path failed");
char *leaf_path = NULL;
char search_path[MAX_PATH_LEN] = {0, };
{
DIR *dp = NULL;
char *real = NULL;
- char *origin = NULL;
+ g_autofree gchar *origin = NULL;
#ifndef _USE_TVPD_MODE
char result_path[MAX_PATH_LEN] = {0, };
#endif
if (dp == NULL) {
if (errno == EACCES || errno == EPERM) {
content_stderror("open dir fail");
- content_sec_error("path [%s]", path);
return MEDIA_CONTENT_ERROR_PERMISSION_DENIED;
} else {
content_stderror("open dir fail");
- content_sec_error("path [%s]", path);
return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
}
#ifdef _USE_TVPD_MODE
if (g_strcmp0(real, origin) != 0) {
content_error("symbolic link(directory)");
- content_sec_debug("path[%s] real[%s]", origin, real);
SAFE_FREE(real);
- g_free(origin);
return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
#else
snprintf(result_path, MAX_PATH_LEN, "%s%s", tzplatform_getenv(TZ_USER_MEDIASHARED), real + strlen(tzplatform_getenv(TZ_SYS_MEDIASHARED)));
if (g_strcmp0(result_path, origin) != 0) {
content_error("symbolic link(directory)");
- content_sec_debug("path[%s] real[%s]", origin, real);
SAFE_FREE(real);
- g_free(origin);
return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
} else {
if (g_strcmp0(real, origin) != 0) {
content_error("symbolic link(directory)");
- content_sec_debug("path[%s] real[%s]", origin, real);
SAFE_FREE(real);
- g_free(origin);
return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
}
#endif
SAFE_FREE(real);
- g_free(origin);
return MEDIA_CONTENT_ERROR_NONE;
}