From 14d279a5c22d886c19aa24620cad9f2570b15e70 Mon Sep 17 00:00:00 2001 From: Kapil Jhuria Date: Sat, 23 Sep 2017 14:42:32 +0530 Subject: [PATCH] Svace fixed in Music Player Change-Id: Ica594fc0f963420d40917a589da639b540fc9b36 --- music-chooser/src/mc-common.c | 8 ++--- music-chooser/src/mc-group-list.c | 1 + music-chooser/src/mc-group-play-list.c | 15 +++++---- music-chooser/src/mc-index.c | 3 +- music-chooser/src/mc-track-list.c | 7 ++-- src/common/mp-media-info.c | 2 +- src/core/mp-lyric-mgr.c | 3 +- src/core/mp-playlist-mgr.c | 14 ++++++-- src/core/mp-setting-ctrl.c | 12 +++++-- src/mp-main.c | 33 ++++++++++--------- src/widget/mp-artist-detail-list.c | 11 ++++--- src/widget/mp-list.c | 11 ++++--- src/widget/mp-lyric.c | 10 +++--- widget/src/mp-widget-create.c | 44 ++++++++++++++------------ 14 files changed, 100 insertions(+), 74 deletions(-) diff --git a/music-chooser/src/mc-common.c b/music-chooser/src/mc-common.c index 7e526f3..5967d36 100644 --- a/music-chooser/src/mc-common.c +++ b/music-chooser/src/mc-common.c @@ -197,7 +197,7 @@ bool mc_is_call_connected(void) return false; } - for (int i=0;i 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)); } } diff --git a/music-chooser/src/mc-group-list.c b/music-chooser/src/mc-group-list.c index be8fabf..34502a5 100644 --- a/music-chooser/src/mc-group-list.c +++ b/music-chooser/src/mc-group-list.c @@ -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); diff --git a/music-chooser/src/mc-group-play-list.c b/music-chooser/src/mc-group-play-list.c index 9f7b85f..f7282b6 100644 --- a/music-chooser/src/mc-group-play-list.c +++ b/music-chooser/src/mc-group-play-list.c @@ -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); diff --git a/music-chooser/src/mc-index.c b/music-chooser/src/mc-index.c index 6018b6a..8a258f6 100644 --- a/music-chooser/src/mc-index.c +++ b/music-chooser/src/mc-index.c @@ -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) diff --git a/music-chooser/src/mc-track-list.c b/music-chooser/src/mc-track-list.c index df50007..854eb49 100644 --- a/music-chooser/src/mc-track-list.c +++ b/music-chooser/src/mc-track-list.c @@ -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) diff --git a/src/common/mp-media-info.c b/src/common/mp-media-info.c index 796788f..2c0344a 100644 --- a/src/common/mp-media-info.c +++ b/src/common/mp-media-info.c @@ -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) { diff --git a/src/core/mp-lyric-mgr.c b/src/core/mp-lyric-mgr.c index 60e16a7..c7a6723 100644 --- a/src/core/mp-lyric-mgr.c +++ b/src/core/mp-lyric-mgr.c @@ -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; diff --git a/src/core/mp-playlist-mgr.c b/src/core/mp-playlist-mgr.c index 261ca72..d768de9 100644 --- a/src/core/mp-playlist-mgr.c +++ b/src/core/mp-playlist-mgr.c @@ -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; } diff --git a/src/core/mp-setting-ctrl.c b/src/core/mp-setting-ctrl.c index 54924fe..f55c7d3 100644 --- a/src/core/mp-setting-ctrl.c +++ b/src/core/mp-setting-ctrl.c @@ -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); diff --git a/src/mp-main.c b/src/mp-main.c index 9bf7874..abf7245 100644 --- a/src/mp-main.c +++ b/src/mp-main.c @@ -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; } diff --git a/src/widget/mp-artist-detail-list.c b/src/widget/mp-artist-detail-list.c index 91df586..e82f786 100644 --- a/src/widget/mp-artist-detail-list.c +++ b/src/widget/mp-artist-detail-list.c @@ -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) diff --git a/src/widget/mp-list.c b/src/widget/mp-list.c index c90df5c..6794e2a 100644 --- a/src/widget/mp-list.c +++ b/src/widget/mp-list.c @@ -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) diff --git a/src/widget/mp-lyric.c b/src/widget/mp-lyric.c index 6fda3d8..ced205c 100644 --- a/src/widget/mp-lyric.c +++ b/src/widget/mp-lyric.c @@ -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(""); - 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(""); - 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); diff --git a/widget/src/mp-widget-create.c b/widget/src/mp-widget-create.c index e28e540..0c41ac2 100644 --- a/widget/src/mp-widget-create.c +++ b/widget/src/mp-widget-create.c @@ -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