Svace fixed in Music Player 07/152007/4
authorKapil Jhuria <kapil.jhuria@samsung.com>
Sat, 23 Sep 2017 09:12:32 +0000 (14:42 +0530)
committerKapil Jhuria <kapil.jhuria@samsung.com>
Sat, 23 Sep 2017 10:44:22 +0000 (16:14 +0530)
Change-Id: Ica594fc0f963420d40917a589da639b540fc9b36

14 files changed:
music-chooser/src/mc-common.c
music-chooser/src/mc-group-list.c
music-chooser/src/mc-group-play-list.c
music-chooser/src/mc-index.c
music-chooser/src/mc-track-list.c
src/common/mp-media-info.c
src/core/mp-lyric-mgr.c
src/core/mp-playlist-mgr.c
src/core/mp-setting-ctrl.c
src/mp-main.c
src/widget/mp-artist-detail-list.c
src/widget/mp-list.c
src/widget/mp-lyric.c
widget/src/mp-widget-create.c

index 7e526f3..5967d36 100644 (file)
@@ -197,7 +197,7 @@ bool mc_is_call_connected(void)
                return false;
        }
 
-       for (int i=0;i<tel_list.count;i++) {
+       for (int i = 0; i < tel_list.count; i++) {
                ret_sim =
                                telephony_call_get_call_list(tel_list.handle[i], &count_sim[i],
                                                &call_list_sim);
@@ -669,7 +669,7 @@ const char *mc_common_search_markup_keyword(const char *string,
                        char *temp = (char *) calloc((word_len + 1), sizeof(char));
                        MP_CHECK_NULL(temp);
                        if (strlen(string) <= DEF_BUF_LEN) {
-                               strncpy(temp, string, strlen(string));
+                               strncpy(temp, string, (strlen(string) + 1));
                        }
                        i = 0;
                        while (word_len > DEF_BUF_LEN) {
@@ -691,12 +691,12 @@ const char *mc_common_search_markup_keyword(const char *string,
                                i++;
                        }
                        if (strlen(temp) <= DEF_BUF_LEN) {
-                               strncpy(pstr, temp, strlen(temp));
+                               strncpy(pstr, temp, (strlen(temp) + 1));
                        }
                        IF_FREE(temp);
                } else {
                        if (strlen(string) <= DEF_BUF_LEN) {
-                               strncpy(pstr, string, strlen(string));
+                               strncpy(pstr, string, (strlen(string) + 1));
                        }
                }
 
index be8fabf..34502a5 100644 (file)
@@ -66,6 +66,7 @@ static void _gl_sel_cb(void *data, Evas_Object * obj, void *event_info)
 
        list_item_data_t *item_data =
                (list_item_data_t *) elm_object_item_data_get(event_info);
+       MP_CHECK(item_data);
        mp_media_info_h media = item_data->media;
        MP_CHECK(media);
        mp_media_info_group_get_main_info(media, &name);
index 9f7b85f..f7282b6 100644 (file)
@@ -139,9 +139,8 @@ static unsigned int _get_select_count(void *data)   //(Evas_Object *genlist)
                        count++;
                }
        }
-       return count;
-
        endfunc;
+       return count;
 }
 
 static void _gl_sel_cb(void *data, Evas_Object * obj, void *event_info)
@@ -251,10 +250,11 @@ static void _mc_track_list_select_all_cb(void *data, Evas_Object * obj,
 
        while (item) {
                list_item_data_t *it_data = elm_object_item_data_get(item);
-
-               if (!it_data->checked) {
-                       all_selected = EINA_TRUE;
-                       break;
+               if (it_data != NULL) {
+                       if (!it_data->checked) {
+                               all_selected = EINA_TRUE;
+                               break;
+                       }
                }
                item = elm_genlist_item_next_get(item);
        }
@@ -262,8 +262,9 @@ static void _mc_track_list_select_all_cb(void *data, Evas_Object * obj,
        item = elm_genlist_first_item_get(ld->genlist);
        while (item) {
                list_item_data_t *it_data = elm_object_item_data_get(item);
+               if (it_data)
+                       it_data->checked = all_selected;
 
-               it_data->checked = all_selected;
                elm_genlist_item_fields_update(item, "elm.edit.icon.1",
                                                                           ELM_GENLIST_ITEM_FIELD_CONTENT);
                item = elm_genlist_item_next_get(item);
index 6018b6a..8a258f6 100644 (file)
@@ -66,8 +66,7 @@ static const char *_mc_list_item_get_label(Elm_Object_Item * event_info)
        char *title = NULL;
 
        list_item_data_t *item_data = elm_object_item_data_get(event_info);
-       if (!item_data || item_data->list_type < MC_TRACK
-               || item_data->list_type > MC_FOLDER_TRACK) {
+       if (!item_data || item_data->list_type > MC_FOLDER_TRACK) {
                return NULL;
        }
        if ((item_data->list_type == MC_TRACK)
index df50007..854eb49 100644 (file)
@@ -436,9 +436,8 @@ static long long int _get_total_size(void *data)
                item_size = item_size + mpFileInfo.st_size;
                item = elm_genlist_item_next_get(item);
        }
-       return item_size;
-
        endfunc;
+       return item_size;
 }
 
 static unsigned int _get_media_list_count(void *data)
@@ -464,12 +463,12 @@ static unsigned int _get_media_list_count(void *data)
        }
        if (count > 0) {
                count = count - 1;
+               endfunc;
                return count;
        } else {
+               endfunc;
                return -1;
        }
-
-       endfunc;
 }
 
 unsigned int _get_select_count(void *data)     //(Evas_Object *genlist)
index 796788f..2c0344a 100644 (file)
@@ -1394,7 +1394,7 @@ int mp_media_info_get_year(mp_media_info_h media, char **year)
        }
        if (!g_strcmp0(media->i.minfo->year, "Unknown")) {
                char *default_year = g_strdup("2014");
-               strncpy(media->i.minfo->year, default_year, strlen(default_year));
+               strncpy(media->i.minfo->year, default_year, (strlen(default_year) + 1));
                IF_G_FREE(default_year);
        }
        if (media->i.minfo->year) {
index 60e16a7..c7a6723 100644 (file)
@@ -36,6 +36,7 @@
 #define MP_LYRIC_PARSE_END_INDEX "]"
 #define MP_LYRIC_PARSE_START_CHAR '['
 #define MP_LYRIC_PARSE_END_CHAR ']'
+#define SYNC_MAX_LEN 9999
 
 static long _mp_lyric_mgr_str2time(const char *text);
 static void _mp_lyric_mgr_data_free(mp_lyric_mgr_t ** data);
@@ -454,7 +455,7 @@ _mp_parse_lyric(mp_lyric_mgr_t * lyric_mgr, const char *musicPath)
                if (sync_len || unsync_len) {
                        DEBUG_TRACE("sync_len=%d", sync_len);
 
-                       if (sync_len > 0) {
+                       if (sync_len > 0 && sync_len <= SYNC_MAX_LEN) {
                                int ret = 0;
                                int idx = 0;
                                unsigned long time_info = 0;
index 261ca72..d768de9 100644 (file)
@@ -670,8 +670,8 @@ int mp_playlist_mgr_get_repeat(mp_plst_mgr * playlist_mgr)
        startfunc;
        MP_CHECK_VAL(playlist_mgr, 0);
 
-       return playlist_mgr->repeat_state;
        endfunc;
+       return playlist_mgr->repeat_state;
 }
 
 int mp_playlist_mgr_set_item_change_callback(mp_plst_mgr * playlist_mgr,
@@ -832,7 +832,11 @@ static Eina_Bool _mp_playlist_mgr_lazy_appender_timer_cb(void *data)
                /* uri */
                if (fgets(line, MAX_NAM_LEN, appender->fp)) {
                        line[MAX_NAM_LEN] = 0;
-                       line[strlen(line) - 1] = 0;
+                       int length = strlen(line);
+                       if (length > 1)
+                               line[length - 1] = 0;
+                       else
+                               line[0] = 0;
                } else {
                        break;
                }
@@ -916,7 +920,11 @@ mp_plst_item *mp_playlist_mgr_lazy_append_with_file(mp_plst_mgr *
                        /* uri */
                        if (fgets(line, MAX_NAM_LEN, fp)) {
                                line[MAX_NAM_LEN] = 0;
-                               line[strlen(line) - 1] = 0;
+                               int length = strlen(line);
+                               if (length > 1)
+                                       line[length - 1] = 0;
+                               else
+                                       line[0] = 0;
                        } else {
                                break;
                        }
index 54924fe..f55c7d3 100644 (file)
@@ -491,7 +491,11 @@ int mp_setting_get_nowplaying_id(void)
        }
        if (fgets(line, MAX_NAM_LEN, fp)) {     /* pid */
                line[MAX_NAM_LEN] = 0;
-               line[strlen(line) - 1] = 0;
+               int length = strlen(line);
+               if (length > 1)
+                       line[length - 1] = 0;
+               else
+                       line[0] = 0;
                pid = atoi(line);
        }
        fclose(fp);
@@ -740,7 +744,11 @@ void mp_setting_get_now_playing_path_from_file(char **path)
                }
                if (fgets(line, MAX_NAM_LEN, fp)) {     /* uri */
                        line[MAX_NAM_LEN] = 0;
-                       line[strlen(line) - 1] = 0;
+                       int length = strlen(line);
+                       if (length > 1)
+                               line[length - 1] = 0;
+                       else
+                               line[0] = 0;
                        *path = g_strdup(line);
                }
                fclose(fp);
index 9bf7874..abf7245 100644 (file)
@@ -78,6 +78,7 @@ static char *test_uri;
 #ifdef MP_FEATURE_EXIT_ON_BACK
 #define MP_EXIT_ON_BACK "ExitOnBack"
 #endif
+#define COUNT_MAX_VALUE 9999
 
 struct appdata *g_ad;
 static bool g_normal_launched = false;
@@ -682,20 +683,22 @@ _mp_main_parse_request_type(struct appdata *ad, app_control_h app_control,
                        }
 
                        mp_playlist_mgr_clear(ad->playlist_mgr);
-                       for (i = 0; i < count; i++, str = NULL) {
-                               token =
-                                       strtok_r(str, MP_EXTRA_KEY_PLAY_FILE_DELIM, &save_ptr);
-                               if (token == NULL) {
-                                       break;
-                               }
-                               if (count == 1) {
-                                       mp_playlist_mgr_item_append(ad->playlist_mgr, token,
-                                                                                               NULL, title, NULL,
-                                                                                               MP_TRACK_URI);
-                               } else {
-                                       mp_playlist_mgr_item_append(ad->playlist_mgr, token,
-                                                                                               NULL, NULL, NULL,
-                                                                                               MP_TRACK_URI);
+                       if (count > 0 && count <= COUNT_MAX_VALUE) {
+                               for (i = 0; i < count; i++, str = NULL) {
+                                       token =
+                                                       strtok_r(str, MP_EXTRA_KEY_PLAY_FILE_DELIM, &save_ptr);
+                                       if (token == NULL) {
+                                               break;
+                                       }
+                                       if (count == 1) {
+                                               mp_playlist_mgr_item_append(ad->playlist_mgr, token,
+                                                               NULL, title, NULL,
+                                                               MP_TRACK_URI);
+                                       } else {
+                                               mp_playlist_mgr_item_append(ad->playlist_mgr, token,
+                                                               NULL, NULL, NULL,
+                                                               MP_TRACK_URI);
+                                       }
                                }
                        }
                        mp_playlist_mgr_set_current(ad->playlist_mgr,
@@ -994,7 +997,7 @@ _mp_main_parse_livebox_event(app_control_h app_control,
 
        return ret;
 
-       IF_FREE(value);
+       //IF_FREE(value);
 #endif
        return 0;
 }
index 91df586..e82f786 100644 (file)
@@ -516,8 +516,8 @@ static int _mp_artist_detail_list_append_album_tracks(void *thiz,
        list->track_lists = g_list_append(list->track_lists, svc_handle);
        return real_count;
   END:
-       return 0;
        endfunc;
+       return 0;
 }
 
 static void _free_track_lists(void *data)
@@ -1096,10 +1096,11 @@ _mp_artist_detail_list_selected_item_data_get(void *thiz,
 
                item = mp_list_item_next_get(item);
        }
-  END:
-       if (selected || sel_list) {
-               *selected = sel_list;
-       }
+       *selected = sel_list;
+       return;
+
+       END:
+       *selected = sel_list;
 }
 
 static char *_mp_artist_detail_list_bottom_counter_text_cb(void *thiz)
index c90df5c..6794e2a 100644 (file)
@@ -383,7 +383,7 @@ static void _mp_list_edit_mode_sel(void *thiz, void *data)
                        ad->checkedList = g_list_append(ad->checkedList, g_strdup(uri));
                } else {
                        GList *list;
-                       for(list = ad->checkedList; list != NULL; list = list->next) {
+                       for (list = ad->checkedList; list != NULL; list = list->next) {
                                if (!g_strcmp0(uri, list->data)) {
                                        ad->checkedList = g_list_delete_link(ad->checkedList, list);
                                }
@@ -449,10 +449,11 @@ static void _mp_list_selected_item_data_get(void *thiz, GList ** selected)
                }
                item = mp_list_item_next_get(item);
        }
-  END:
-       if (selected || sel_list) {
-               *selected = sel_list;
-       }
+       *selected = sel_list;
+       return;
+
+       END:
+       *selected = sel_list;
 }
 
 static void _mp_list_all_item_data_get(void *thiz, GList ** selected)
index 6fda3d8..ced205c 100644 (file)
@@ -212,15 +212,15 @@ _mp_lyric_set_line_color(MpLyricData_t * wd, Evas_Object * obj, int index,
                (char *) malloc(sizeof(char) * (strlen(text_old) + 50));
        MP_CHECK(text_new);
        char *text = g_strdup("<color=");
-       strncpy(text_new, text, strlen(text));
+       strncpy(text_new, text, (strlen(text) + 1));
        IF_G_FREE(text);
-       strncat(text_new, color, strlen(color));
+       strncat(text_new, color, (strlen(color) + 1));
        text = g_strdup(">");
-       strncat(text_new, text, strlen(text));
+       strncat(text_new, text, (strlen(text) + 1));
        IF_G_FREE(text);
-       strncat(text_new, text_old, strlen(text_old));
+       strncat(text_new, text_old, (strlen(text_old) + 1));
        text = g_strdup("</color>");
-       strncat(text_new, text, strlen(text));
+       strncat(text_new, text, (strlen(text) + 1));
        IF_G_FREE(text);
 
        edje_object_part_text_set(_EDJ(obj), "txt", text_new);
index e28e540..0c41ac2 100644 (file)
@@ -98,25 +98,27 @@ static void mp_widget_read_ini_file_ecore(void *data, char *path)
                char *value = NULL;
                key = strtok_r(str, "=", &sptr);
                value = strtok_r(NULL, "=", &sptr);
-               DEBUG_TRACE("key is: %s and value is: %s", key, value);
 
-               if (!strcmp(key, " \n")) {
-                       ERROR_TRACE("Current File is removed. No contents.");
-                       line_count++;
+               if (key == NULL) {
+                       DEBUG_TRACE("key is NULL");
                        continue;
                }
 
-               if (value != NULL) {
-                       value[strlen(value) - 1] = '\0';
-               } else {
+               if (value == NULL) {
                        DEBUG_TRACE("value is NULL");
                        continue;
                }
 
-               if (key == NULL) {
+               DEBUG_TRACE("key is: %s and value is: %s", key, value);
+
+               if (!strcmp(key, " \n")) {
+                       ERROR_TRACE("Current File is removed. No contents.");
+                       line_count++;
                        continue;
                }
 
+               value[strlen(value) - 1] = '\0';
+
                if (!strcmp(key, " ")) {
                        ERROR_TRACE("Cannot determine key");
                        fclose(file);
@@ -142,7 +144,7 @@ static void mp_widget_read_ini_file_ecore(void *data, char *path)
                        wgtdata->file_path =
                                (char *) malloc((strlen(value) + 1) * sizeof(char));
                        if (wgtdata->file_path) {
-                               strncpy(wgtdata->file_path, value, strlen(value));
+                               strncpy(wgtdata->file_path, value, (strlen(value) + 1));
                                wgtdata->file_path[strlen(value)] = '\0';
                        }
                }
@@ -158,7 +160,7 @@ static void mp_widget_read_ini_file_ecore(void *data, char *path)
                                        (char *) malloc((strlen(value) + 1) * sizeof(char));
 
                                if (image_path != NULL) {
-                                       strncpy(image_path, value, strlen(value));
+                                       strncpy(image_path, value, (strlen(value) + 1));
                                        image_path[strlen(value)] = '\0';
 
                                        if (!strcmp(BROKEN_ALBUMART_IMAGE_PATH, image_path)) {
@@ -311,7 +313,7 @@ static void mp_widget_read_ini_file(char *path, void *data)
                                (char *) malloc((strlen(value) + 1) * sizeof(char));
 
                        if (wgtdata->file_path) {
-                               strncpy(wgtdata->file_path, value, strlen(value));
+                               strncpy(wgtdata->file_path, value, (strlen(value) + 1));
                                wgtdata->file_path[strlen(value)] = '\0';
                        }
                }
@@ -326,7 +328,7 @@ static void mp_widget_read_ini_file(char *path, void *data)
                                image_path =
                                        (char *) malloc((strlen(value) + 1) * sizeof(char));
                                if (image_path) {
-                                       strncpy(image_path, value, strlen(value));
+                                       strncpy(image_path, value, (strlen(value) + 1));
                                        image_path[strlen(value)] = '\0';
 
                                        if (!strcmp(BROKEN_ALBUMART_IMAGE_PATH, image_path)) {
@@ -572,6 +574,8 @@ static bool telephony_is_call_connected(void)
        telephony_handle_list_s tel_list;
        telephony_error_e ret_sim;
        unsigned int count_sim[2];
+       count_sim[0] = 0;
+       count_sim[1] = 0;
 
        int tel_valid = telephony_init(&tel_list);
        if (tel_valid != 0) {
@@ -580,7 +584,7 @@ static bool telephony_is_call_connected(void)
                return false;
        }
 
-       for (int i=0;i<tel_list.count;i++) {
+       for (int i = 0; i < tel_list.count; i++) {
                ret_sim =
                                telephony_call_get_call_list(tel_list.handle[i], &count_sim[i],
                                                &call_list_sim);
@@ -662,16 +666,16 @@ static void mp_widget_click_on_play_cb(void *data, Evas_Object * obj,
                extra_data_values[i] = (char *) malloc(50);
        }
 
-       strncpy(extra_data_keys[0], MP_LB_EVENT_KEY, strlen(MP_LB_EVENT_KEY));
+       strncpy(extra_data_keys[0], MP_LB_EVENT_KEY, (strlen(MP_LB_EVENT_KEY) + 1));
        extra_data_keys[0][strlen(MP_LB_EVENT_KEY)] = '\0';
 
        if (!is_play) {
                strncpy(extra_data_values[0], MP_LB_EVENT_PLAY_CLICKED,
-                               strlen(MP_LB_EVENT_PLAY_CLICKED));
+                               (strlen(MP_LB_EVENT_PLAY_CLICKED) + 1));
                extra_data_values[0][strlen(MP_LB_EVENT_PLAY_CLICKED)] = '\0';
        } else {
                strncpy(extra_data_values[0], MP_LB_EVENT_PAUSE_CLICKED,
-                               strlen(MP_LB_EVENT_PAUSE_CLICKED));
+                               (strlen(MP_LB_EVENT_PAUSE_CLICKED) + 1));
                extra_data_values[0][strlen(MP_LB_EVENT_PAUSE_CLICKED)] = '\0';
        }
 
@@ -733,11 +737,11 @@ static void mp_widget_click_on_previous_cb(void *data, Evas_Object * obj,
                extra_data_values[i] = (char *) malloc(50);
        }
 
-       strncpy(extra_data_keys[0], MP_LB_EVENT_KEY, strlen(MP_LB_EVENT_KEY));
+       strncpy(extra_data_keys[0], MP_LB_EVENT_KEY, (strlen(MP_LB_EVENT_KEY) + 1));
        extra_data_keys[0][strlen(MP_LB_EVENT_KEY)] = '\0';
 
        strncpy(extra_data_values[0], MP_LB_EVENT_PREV_RELEASED,
-                       strlen(MP_LB_EVENT_PREV_RELEASED));
+                       (strlen(MP_LB_EVENT_PREV_RELEASED) + 1));
        extra_data_values[0][strlen(MP_LB_EVENT_PREV_RELEASED)] = '\0';
 
        if (message_port_init(extra_data_values[0]) != MESSAGE_PORT_ERROR_NONE) {
@@ -799,11 +803,11 @@ static void mp_widget_click_on_next_cb(void *data, Evas_Object * obj,
                extra_data_values[i] = (char *) malloc(50);
        }
 
-       strncpy(extra_data_keys[0], MP_LB_EVENT_KEY, strlen(MP_LB_EVENT_KEY));
+       strncpy(extra_data_keys[0], MP_LB_EVENT_KEY, (strlen(MP_LB_EVENT_KEY) + 1));
        extra_data_keys[0][strlen(MP_LB_EVENT_KEY)] = '\0';
 
        strncpy(extra_data_values[0], MP_LB_EVENT_NEXT_RELEASED,
-                       strlen(MP_LB_EVENT_NEXT_RELEASED));
+                       (strlen(MP_LB_EVENT_NEXT_RELEASED) + 1));
        extra_data_values[0][strlen(MP_LB_EVENT_NEXT_RELEASED)] = '\0';
 
        if (message_port_init(extra_data_values[0]) != MESSAGE_PORT_ERROR_NONE) {