[M120 Migration] Fix Coverity Potential Defects 22/307522/5
authorManjeet <manjeet.1@partner.samsung.com>
Mon, 11 Mar 2024 17:00:34 +0000 (22:30 +0530)
committerDae-Hyun Ko <dhyuna.ko@samsung.com>
Thu, 14 Mar 2024 05:10:59 +0000 (05:10 +0000)
The following patch fixes below coverity defects.

Warning Group Ids = 1660602, 1079960, 1080164,
1080413, 1080440, 1080471, 1081102, 1081228,
1081511, 1082036, 1083035, 1083228, 1629438,
1637057, 1660550, 1660602

Reference:
https://review.tizen.org/gerrit/294087
https://review.tizen.org/gerrit/294660
https://review.tizen.org/gerrit/293808

Change-Id: I8196bc6f8508ec235109949cf3f52f91e5459e4a
Signed-off-by: Manjeet <manjeet.1@partner.samsung.com>
tizen_src/ewk/efl_integration/private/ewk_context_form_autofill_profile_private.cc
tizen_src/ewk/efl_webview_app/app.c
tizen_src/ewk/ubrowser/browser.cc

index 1fb706b..f0fbcdb 100644 (file)
@@ -78,14 +78,17 @@ void to_Autofill_Profile_set_data(const Ewk_Autofill_Profile* oldStyleProfile,
     DataType DataName,
     std::string locale,
     autofill::AutofillProfile &ret) {
-  std::u16string value;
   static std::map<DataType, autofill::ServerFieldType> profile_map =
       create_EWK_to_Autofill_profile_map();
+  if (profile_map.find(DataName) == profile_map.end()) {
+    return;
+  }
+  std::u16string value;
   if (0 < (value = oldStyleProfile->get16Data(DataName)).length()) {
     if (DataName == PROFILE_NAME || DataName == PROFILE_COUNTRY) {
       ret.SetInfo(autofill::AutofillType(profile_map.find(DataName)->second),
                   value, locale);
-    } else
+    } else if (profile_map.find(DataName) != profile_map.end())
       ret.SetRawInfo(profile_map.find(DataName)->second, value);
   }
 }
@@ -147,7 +150,7 @@ void to_EWK_Profile_set_data(const autofill::AutofillProfile& newStyleProfile,
     value = newStyleProfile.GetRawInfo(DataName);
   }
 
-  if (value.length())
+  if (value.length() && (profile_map.find(DataName) != profile_map.end()))
     ret->setData(profile_map.find(DataName)->second, base::UTF16ToASCII(value));
 }
 
index 15aaed9..a5dc463 100644 (file)
@@ -1071,7 +1071,7 @@ Eina_Bool __notification_permission_cb(Evas_Object* o, Ewk_Notification_Permissi
 void __notification_cancel_cb(uint64_t notification_id, void* event_info)
 {
   evas_object_del(popup);
-  printf("APP.C callback  __notification_cancel_cb with notification id = %Lu\n", (long long unsigned int)notification_id);
+  printf("APP.C callback  __notification_cancel_cb with notification id = %llu\n", notification_id);
 }
 
 void __policy_response_decide_cb(void *data, Evas_Object *obj, void *event_info)
@@ -1208,7 +1208,7 @@ void __customize_context_menu_item_selected_cb(void* data, Evas_Object *obj, voi
       }
       static char snapshot_filename[256];
       static int snapshot_count = 1;
-      sprintf(snapshot_filename, "snapshot_img%04d.%s", snapshot_count++, "png");
+      snprintf(snapshot_filename, sizeof(snapshot_filename), "snapshot_img%04d.%s", snapshot_count++, "png");
       if (evas_object_image_save(snapshot, snapshot_filename, 0, 0))
         printf("Snapshot image saved in %s\n", snapshot_filename);
       else
@@ -1402,7 +1402,7 @@ void __hit_test_request_cb(Evas_Object* o, int x, int y, int hit_test_mode, Ewk_
     evas_object_image_data_copy_set(image, ewk_hit_test_image_buffer_get(ht));
     static char filename_buffer[256];
     static int count = 1;
-    sprintf(filename_buffer, "hit_test_img%04d.%s", count++, ewk_hit_test_image_file_name_extension_get(ht));
+    snprintf(filename_buffer, sizeof(filename_buffer), "hit_test_img%04d.%s", count++, ewk_hit_test_image_file_name_extension_get(ht));
     if (evas_object_image_save(image, filename_buffer, 0, 0))
       printf("Hit test image saved in %s\n", filename_buffer);
     else
index 80a1754..a1d9a29 100644 (file)
@@ -86,23 +86,23 @@ Browser::Browser(bool desktop,
   log_info("UI type: %s", desktop_ ? "desktop" : "mobile");
 
   if (IsDesktopProfile()) {
-    log_info("Runtime Profile : DESKTOP : ", IsDesktopProfile());
+    log_info("Runtime Profile : DESKTOP");
   } else if (IsMobileProfile()) {
-    log_info("Runtime Profile : MOBILE : ", IsMobileProfile());
+    log_info("Runtime Profile : MOBILE");
   } else if (IsTvProfile()) {
-    log_info("Runtime Profile : TV : ", IsTvProfile());
+    log_info("Runtime Profile : TV");
   } else if (IsWearableProfile()) {
-    log_info("Runtime Profile : WEARABLE : ", IsWearableProfile());
+    log_info("Runtime Profile : WEARABLE");
   } else if (IsIviProfile()) {
-    log_info("Runtime Profile : IVI : ", IsIviProfile());
+    log_info("Runtime Profile : IVI");
   } else if (IsCommonProfile()) {
-    log_info("Runtime Profile : COMMON : ", IsCommonProfile());
+    log_info("Runtime Profile : COMMON");
   } else {
-    log_info("Runtime Profile : UNKNOWN : ");
+    log_info("Runtime Profile : UNKNOWN");
   }
 
   if (IsEmulatorArch()) {
-    log_info("Runtime Architecture : EMULATOR : ", IsEmulatorArch());
+    log_info("Runtime Architecture : EMULATOR");
   }
 
   // If we don't call ewk_context_default_get here, ubrowser crashes in desktop
@@ -226,7 +226,7 @@ Window& Browser::CreateWindow(bool incognito) {
   if (window_list_)
     elm_list_go(window_list_);
 
-  log_trace("%s: %x", __PRETTY_FUNCTION__, data.window->Id());
+  log_trace("%s: %p", __PRETTY_FUNCTION__, data.window->Id());
 
   return *data.window;
 }
@@ -305,7 +305,7 @@ void Browser::StopTracing() {
 }
 
 void Browser::StartVibration(uint64_t duration) {
-  log_trace("%s: %d", __PRETTY_FUNCTION__, duration);
+  log_trace("%s: %llu", __PRETTY_FUNCTION__, duration);
 #if BUILDFLAG(IS_TIZEN)
   if (IsMobileProfile() || IsWearableProfile()) {
     if (haptic_timer_id_) {
@@ -350,7 +350,7 @@ void Browser::StopVibration() {
 }
 
 void Browser::OnWindowDestroyed(Window::IdType id) {
-  log_trace("%s: %x", __PRETTY_FUNCTION__, id);
+  log_trace("%s: %p", __PRETTY_FUNCTION__, id);
   assert(window_map_.find(id) != window_map_.end());
   WindowMapData window_map_data = window_map_[id];
   if (window_map_data.list_elm)