Add parameter validation 96/230196/3
authorJusung Son <jusung07.son@samsung.com>
Wed, 8 Apr 2020 10:44:35 +0000 (19:44 +0900)
committerJusung Son <jusung07.son@samsung.com>
Mon, 13 Apr 2020 06:51:29 +0000 (15:51 +0900)
Change-Id: I55ca5ceb6d3deb44eb4e943c7f7f377bfcec7273
Signed-off-by: Jusung Son <jusung07.son@samsung.com>
watchface-complication/watchface-editable.cc
watchface-editor/watchface-editor.cc

index d7ea1a2..fc1b72b 100644 (file)
@@ -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<int>(
       g_list_length(list_handle->candidates_list)))
     return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
index b3408ff..3dd93d8 100644 (file)
@@ -497,6 +497,11 @@ extern "C" EXPORT_API int watchface_editor_editable_candidate_list_get_nth(
   SharedHandle<IEditable>* ptr = static_cast<SharedHandle<IEditable>*>(handle);
   shared_ptr<IEditable> ed = ptr->GetPtr();
   const std::list<std::shared_ptr<Bundle>>& list = ed->GetCandidates();
+  if (nth < 0 || nth >= static_cast<int>(list.size())) {
+    LOGE("Invalid parameter");
+    return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
+  }
+
   const std::list<std::shared_ptr<Bundle>>::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;
   }