From 62483d609acac32754114608bb1b3225db2b6599 Mon Sep 17 00:00:00 2001 From: Shubhojeet Date: Thu, 29 Mar 2018 14:59:00 +0530 Subject: Coverity issues in attach-panel-document Change-Id: Id7cf203fa3658c8a6c76a2dbe4364163db55ffa7 --- src/doc-data-util.c | 3 ++- src/doc-data.c | 10 +++++----- src/doc-list.c | 24 ++++++++++++++++++++---- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/doc-data-util.c b/src/doc-data-util.c index e22e953..082d5a0 100644 --- a/src/doc-data-util.c +++ b/src/doc-data-util.c @@ -176,6 +176,7 @@ bool doc_data_util_clone_media(media_info_h media, doc_media_s ** pitem, item = (doc_media_s *) calloc(1, sizeof(doc_media_s)); DOC_CHECK_FALSE(item); item->gtype = DOC_TYPE_MEDIA; + media_content_storage_e storage_type = 0; if (media_info_clone(&(item->media_h), media) != MEDIA_CONTENT_ERROR_NONE) { @@ -220,7 +221,7 @@ bool doc_data_util_clone_media(media_info_h media, doc_media_s ** pitem, doc_dbgE("Get media mode failed!"); goto DOC_DATA_UTIL_FAILED; } */ - media_content_storage_e storage_type = 0; + if (media_info_get_storage_type(media, &storage_type) != MEDIA_CONTENT_ERROR_NONE) { doc_dbgE("Get storage type failed!"); diff --git a/src/doc-data.c b/src/doc-data.c index 8a02030..a3bf325 100644 --- a/src/doc-data.c +++ b/src/doc-data.c @@ -477,14 +477,14 @@ int doc_data_get_media_data(doc_ugdata * ugd, int type, int start_pos, continue; } doc_dbgE("Chandan:: Item is %s", item->display_name); - fsFileType type = FILE_TYPE_NONE; + fsFileType ftype = FILE_TYPE_NONE; doc_dbgE("1111111"); - document_file_category(item->display_name, &type); - doc_dbgE("Chandan:: Type is %d", type); + document_file_category(item->display_name, &ftype); + doc_dbgE("Chandan:: Type is %d", ftype); bool isUnsupported = false; - switch (type) { + switch (ftype) { case FILE_TYPE_DOC: case FILE_TYPE_PDF: case FILE_TYPE_PPT: @@ -512,7 +512,7 @@ int doc_data_get_media_data(doc_ugdata * ugd, int type, int start_pos, ditem->item = item; ditem->ugd = ugd; - ditem->store_type = type; + ditem->store_type = ftype; *pmedias_elist = eina_list_append(*pmedias_elist, ditem); if (restore_cb && sel_id) diff --git a/src/doc-list.c b/src/doc-list.c index f88393a..5f8b835 100644 --- a/src/doc-list.c +++ b/src/doc-list.c @@ -168,6 +168,7 @@ static void _doc_list_navi_done_cb(void *data, Evas_Object * obj, void *ei) char **path_array = NULL; /* the array size is sel_cnt */ int sel_cnt = 0; int i = 0; + char t_str[32] = { 0, }; doc_data_get_sel_paths(ugd, &paths, &path_array, &sel_cnt); if (sel_cnt <= 0) { @@ -175,7 +176,7 @@ static void _doc_list_navi_done_cb(void *data, Evas_Object * obj, void *ei) goto DOC_SEND_RESULT_FINISHED; } - char t_str[32] = { 0, }; + eina_convert_itoa(sel_cnt, t_str); app_control_add_extra_data(ugd->service, @@ -229,7 +230,12 @@ static void _doc_list_check_state_changed_cb(void *data, Evas_Object * obj, DOC_CHECK(sit); #ifdef FEATURE_SIZE_CHECK struct stat stFileInfo; - stat(sit->file_url, &stFileInfo); + int status = stat(sit->file_url, &stFileInfo); + if (status == -1) { + doc_data_util_free_sel_item(sit); + doc_dbgE("Invalid file url"); + return; + } #endif if (state == EINA_TRUE) { if (!g_strcmp0(item->item->thumb_url, DEFAULT_THUMBNAIL)) { @@ -522,7 +528,12 @@ static void _doc_list_item_sel_cb(void *data, Evas_Object * obj, void *ei) } #ifdef FEATURE_SIZE_CHECK struct stat stFileInfo; - stat(sit->file_url, &stFileInfo); + int status = stat(sit->file_url, &stFileInfo); + if (status == -1) { + doc_data_util_free_sel_item(sit); + doc_dbgE("Invalid file url"); + return; + } if (ugd->limitsize > 0 && ugd->selsize + stFileInfo.st_size > ugd->limitsize) { notification_status_message_post @@ -548,7 +559,12 @@ static void _doc_list_item_sel_cb(void *data, Evas_Object * obj, void *ei) } #ifdef FEATURE_SIZE_CHECK struct stat stFileInfo; - stat(sit->file_url, &stFileInfo); + int status = stat(sit->file_url, &stFileInfo); + if (status == -1) { + doc_data_util_free_sel_item(sit); + doc_dbgE("Invalid file url"); + return; + } #endif doc_sdbg("remove Path: %s", sit->file_url); EINA_LIST_FOREACH(ugd->selected_elist, l, sit1) { -- cgit v1.2.3