From: Jusung Son Date: Wed, 8 Apr 2020 10:44:35 +0000 (+0900) Subject: Add parameter validation X-Git-Tag: accepted/tizen/unified/20200424.141651~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8f474a0af183b9dfc4570ac4e3b6052ae24939cb;p=platform%2Fcore%2Fappfw%2Fwatchface-complication.git Add parameter validation Change-Id: I55ca5ceb6d3deb44eb4e943c7f7f377bfcec7273 Signed-off-by: Jusung Son --- diff --git a/watchface-complication/watchface-editable.cc b/watchface-complication/watchface-editable.cc index d7ea1a2..fc1b72b 100644 --- a/watchface-complication/watchface-editable.cc +++ b/watchface-complication/watchface-editable.cc @@ -178,7 +178,7 @@ extern "C" EXPORT_API int watchface_editable_add_design_element( list_handle->candidates_list == nullptr) return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER; - if (cur_data_idx < 0 && + if (cur_data_idx < 0 || cur_data_idx >= static_cast( g_list_length(list_handle->candidates_list))) return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER; diff --git a/watchface-editor/watchface-editor.cc b/watchface-editor/watchface-editor.cc index b3408ff..3dd93d8 100644 --- a/watchface-editor/watchface-editor.cc +++ b/watchface-editor/watchface-editor.cc @@ -497,6 +497,11 @@ extern "C" EXPORT_API int watchface_editor_editable_candidate_list_get_nth( SharedHandle* ptr = static_cast*>(handle); shared_ptr ed = ptr->GetPtr(); const std::list>& list = ed->GetCandidates(); + if (nth < 0 || nth >= static_cast(list.size())) { + LOGE("Invalid parameter"); + return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER; + } + const std::list>::const_iterator it = list.begin(); auto nx = std::next(it, nth); @@ -563,7 +568,7 @@ extern "C" EXPORT_API int watchface_editor_is_setup_app_exist( if (!watchface_complication::util::CheckWatchFeatureEnabled()) return WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED; - if (handle == NULL) { + if (handle == NULL || exist == NULL) { LOGE("Invalid parameter"); return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER; }