From: Haejeong, Kim Date: Fri, 16 Oct 2015 02:04:50 +0000 (+0900) Subject: Prevent issue fix X-Git-Tag: submit/tizen/20151016.024419 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Ftags%2Fsubmit%2Ftizen%2F20151016.024419;p=platform%2Fcore%2Fmultimedia%2Flibmedia-service.git Prevent issue fix Change-Id: I19d995d6e5c5db230aba357384eeedaca8b96fc2 --- diff --git a/packaging/libmedia-service.spec b/packaging/libmedia-service.spec index 7520392..648a2d1 100644 --- a/packaging/libmedia-service.spec +++ b/packaging/libmedia-service.spec @@ -1,6 +1,6 @@ Name: libmedia-service Summary: Media information service library for multimedia applications -Version: 0.2.58 +Version: 0.2.59 Release: 0 Group: System/Libraries License: Apache-2.0 and public domain diff --git a/src/common/media-svc-db-utils.c b/src/common/media-svc-db-utils.c index dbf4a74..419b6cd 100755 --- a/src/common/media-svc-db-utils.c +++ b/src/common/media-svc-db-utils.c @@ -69,7 +69,7 @@ char *_media_svc_get_path(uid_t uid) media_svc_error("UID [%d] does not belong to 'users' group!", uid); return NULL; } - sprintf(passwd_str, "%s/%s", userinfo->pw_dir, MEDIA_CONTENT_PATH); + snprintf(passwd_str, sizeof(passwd_str), "%s/%s", userinfo->pw_dir, MEDIA_CONTENT_PATH); result_passwd = g_strdup(passwd_str); } diff --git a/src/common/media-svc-media-folder.c b/src/common/media-svc-media-folder.c index 69266ab..571716e 100755 --- a/src/common/media-svc-media-folder.c +++ b/src/common/media-svc-media-folder.c @@ -39,7 +39,7 @@ static int __media_svc_is_root_path(const char *folder_path, bool *is_root, uid_ char *internal_path = _media_svc_get_path(uid); if ((STRING_VALID(internal_path) && (strcmp(folder_path, internal_path) == 0)) || - strcmp(folder_path, MEDIA_ROOT_PATH_SDCARD) == 0 || + (STRING_VALID(MEDIA_ROOT_PATH_SDCARD) && strcmp(folder_path, MEDIA_ROOT_PATH_SDCARD) == 0) || (STRING_VALID(MEDIA_ROOT_PATH_CLOUD) && strcmp(folder_path, MEDIA_ROOT_PATH_CLOUD) == 0)) { media_svc_debug("ROOT PATH [%s]", folder_path); *is_root = TRUE; @@ -230,11 +230,11 @@ static int __media_svc_get_and_append_parent_folder(sqlite3 *handle, const char if (STRING_VALID(internal_path) && (strncmp(path, internal_path, strlen(internal_path)) == 0)) next_pos = strlen(internal_path); - else if (strncmp(path, MEDIA_ROOT_PATH_SDCARD, strlen(MEDIA_ROOT_PATH_SDCARD)) == 0) + else if (STRING_VALID(MEDIA_ROOT_PATH_SDCARD) && strncmp(path, MEDIA_ROOT_PATH_SDCARD, strlen(MEDIA_ROOT_PATH_SDCARD)) == 0) next_pos = strlen(MEDIA_ROOT_PATH_SDCARD); else if (STRING_VALID(MEDIA_ROOT_PATH_CLOUD) && (strncmp(path, MEDIA_ROOT_PATH_CLOUD, strlen(MEDIA_ROOT_PATH_CLOUD)) == 0)) next_pos = strlen(MEDIA_ROOT_PATH_CLOUD); - else if (strncmp(path, MEDIA_ROOT_PATH_EXTERNAL, strlen(MEDIA_ROOT_PATH_EXTERNAL)) == 0) + else if (STRING_VALID(MEDIA_ROOT_PATH_EXTERNAL) && strncmp(path, MEDIA_ROOT_PATH_EXTERNAL, strlen(MEDIA_ROOT_PATH_EXTERNAL)) == 0) next_pos = strlen(MEDIA_ROOT_PATH_EXTERNAL); else { media_svc_error("Invalid Path"); diff --git a/src/common/media-svc-media.c b/src/common/media-svc-media.c index 601e99f..81366b8 100755 --- a/src/common/media-svc-media.c +++ b/src/common/media-svc-media.c @@ -200,7 +200,7 @@ char *_media_svc_get_thumb_default_path(uid_t uid) media_svc_error("UID [%d] does not belong to 'users' group!", uid); return NULL; } - sprintf(passwd_str, "%s/share/media/.thumb/thumb_default.png", userinfo->pw_dir); + snprintf(passwd_str, sizeof(passwd_str), "%s/share/media/.thumb/thumb_default.png", userinfo->pw_dir); result_passwd = g_strdup(passwd_str); } diff --git a/src/common/media-svc-storage.c b/src/common/media-svc-storage.c index c8a675e..5f5814d 100755 --- a/src/common/media-svc-storage.c +++ b/src/common/media-svc-storage.c @@ -198,7 +198,7 @@ int _media_svc_get_storage_uuid(sqlite3 *handle, const char *path, char *storage char *remain_path = NULL; int remain_len = 0; - if (strncmp(path, MEDIA_ROOT_PATH_INTERNAL, strlen(MEDIA_ROOT_PATH_INTERNAL)) == 0) { + if (STRING_VALID(MEDIA_ROOT_PATH_INTERNAL) && strncmp(path, MEDIA_ROOT_PATH_INTERNAL, strlen(MEDIA_ROOT_PATH_INTERNAL)) == 0) { _strncpy_safe(storage_id, MEDIA_SVC_DB_TABLE_MEDIA, MEDIA_SVC_UUID_SIZE+1); return MS_MEDIA_ERR_NONE; } diff --git a/src/common/media-svc-util.c b/src/common/media-svc-util.c index f3dd988..2896488 100755 --- a/src/common/media-svc-util.c +++ b/src/common/media-svc-util.c @@ -589,7 +589,7 @@ static char *__media_svc_get_thumb_path(uid_t uid) media_svc_error("UID [%d] does not belong to 'users' group!", uid); return NULL; } - sprintf(passwd_str, "%s/share/media/.thumb", userinfo->pw_dir); + snprintf(passwd_str, sizeof(passwd_str), "%s/share/media/.thumb", userinfo->pw_dir); result_passwd = g_strdup(passwd_str); } @@ -727,7 +727,7 @@ int _media_svc_remove_all_files_in_dir(const char *dir_path) struct dirent entry; struct dirent *result; struct stat st; - char filename[MEDIA_SVC_PATHNAME_SIZE] = {0}; + char filename[MEDIA_SVC_PATHNAME_SIZE] = {0, }; DIR *dir = NULL; dir = opendir(dir_path); @@ -790,7 +790,7 @@ char *_media_svc_get_thumb_internal_path(uid_t uid) media_svc_error("UID [%d] does not belong to 'users' group!", uid); return NULL; } - sprintf(passwd_str, "%s/share/media/.thumb/phone", userinfo->pw_dir); + snprintf(passwd_str, sizeof(passwd_str), "%s/share/media/.thumb/phone", userinfo->pw_dir); result_passwd = g_strdup(passwd_str); } @@ -825,7 +825,7 @@ char *_media_svc_get_thumb_external_path(uid_t uid) media_svc_error("UID [%d] does not belong to 'users' group!", uid); return NULL; } - sprintf(passwd_str, "%s/share/media/.thumb/mmc", userinfo->pw_dir); + snprintf(passwd_str, sizeof(passwd_str), "%s/share/media/.thumb/mmc", userinfo->pw_dir); result_passwd = g_strdup(passwd_str); } @@ -2045,7 +2045,7 @@ int _media_svc_get_storage_type_by_path(const char *path, media_svc_storage_type { if (STRING_VALID(path)) { char *internal_path = _media_svc_get_path(uid); - if (strncmp(path, internal_path, strlen(internal_path)) == 0) { + if (STRING_VALID(internal_path) && (strncmp(path, internal_path, strlen(internal_path)) == 0)) { *storage_type = MEDIA_SVC_STORAGE_INTERNAL; } else if (STRING_VALID(MEDIA_ROOT_PATH_SDCARD) && (strncmp(path, MEDIA_ROOT_PATH_SDCARD, strlen(MEDIA_ROOT_PATH_SDCARD)) == 0)) { *storage_type = MEDIA_SVC_STORAGE_EXTERNAL; diff --git a/src/common/media-svc.c b/src/common/media-svc.c index b84661d..81782c4 100755 --- a/src/common/media-svc.c +++ b/src/common/media-svc.c @@ -776,7 +776,8 @@ int media_svc_delete_all_items_in_storage(MediaSvcHandle *handle, const char *st const char *dirpath = (storage_type == MEDIA_SVC_STORAGE_INTERNAL) ? internal_thumb_path : external_thumb_path; /* remove thumbnails */ - ret = _media_svc_remove_all_files_in_dir(dirpath); + if (STRING_VALID(dirpath)) + ret = _media_svc_remove_all_files_in_dir(dirpath); SAFE_FREE(internal_thumb_path); SAFE_FREE(external_thumb_path); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); @@ -1046,7 +1047,7 @@ int media_svc_rename_folder(MediaSvcHandle *handle, const char *storage_id, cons /* If old thumb path is default or not */ char *default_thumbnail_path = _media_svc_get_thumb_default_path(uid); if (STRING_VALID(default_thumbnail_path) && (strncmp(media_thumb_path, default_thumbnail_path, strlen(default_thumbnail_path)) == 0)) { - strncpy(media_new_thumb_path, default_thumbnail_path, sizeof(media_new_thumb_path)); + strncpy(media_new_thumb_path, default_thumbnail_path, sizeof(media_new_thumb_path) - 1); } else { ret = _media_svc_get_storage_type_by_path(replaced_path, &storage_type, uid); if (ret != MS_MEDIA_ERR_NONE) {