Fix wrong category of the media from mime 15/194615/1
authorjiyong.min <jiyong.min@samsung.com>
Wed, 5 Dec 2018 04:38:44 +0000 (13:38 +0900)
committerJiyong Min <jiyong.min@samsung.com>
Thu, 6 Dec 2018 09:01:09 +0000 (09:01 +0000)
Change-Id: Ia6f99d5a61a43a895fbc50183623144c9f72a3ed

src/common/media-svc-util.c

index 329ebbd..fc0ae7f 100755 (executable)
@@ -332,11 +332,15 @@ static int __media_svc_get_content_type_from_mime(const char *path, const char *
 {
        int idx = 0;
 
+       media_svc_retvm_if(path == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "path is null");
+       media_svc_retvm_if(mimetype == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "mimetype is null");
+       media_svc_retvm_if(category == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "category is null");
+
        *category = MEDIA_SVC_CATEGORY_UNKNOWN;
 
        /*categorize from mimetype */
        for (idx = 0; idx < CONTENT_TYPE_NUM; idx++) {
-               if (strstr(mimetype, content_category[idx].content_type) != NULL) {
+               if (strncmp(mimetype, content_category[idx].content_type, strlen(content_category[idx].content_type)) == 0) {
                        *category = (*category | content_category[idx].category_by_mime);
                        break;
                }
@@ -344,7 +348,7 @@ static int __media_svc_get_content_type_from_mime(const char *path, const char *
 
        /*in application type, exitst sound file ex) x-smafs, asf */
        if (*category & MEDIA_SVC_CATEGORY_ETC) {
-               int prefix_len = strlen(content_category[0].content_type);
+               int prefix_len = strlen(content_category[MEDIA_SVC_CATEGORY_ETC].content_type) + 1;
                char *ext = NULL;
 
                for (idx = 0; idx < SOUND_MIME_NUM; idx++) {
@@ -384,7 +388,7 @@ static int __media_svc_get_content_type_from_mime(const char *path, const char *
 
        /*check music file in sound files. */
        if (*category & MEDIA_SVC_CATEGORY_SOUND) {
-               int prefix_len = strlen(content_category[0].content_type) + 1;
+               int prefix_len = strlen(content_category[MEDIA_SVC_CATEGORY_SOUND].content_type) + 1;
 
                for (idx = 0; idx < MUSIC_MIME_NUM; idx++) {
                        if (strcmp(mimetype + prefix_len, music_mime_table[idx]) == 0) {