[M108 Migration] Use snprintf in place of sprintf 07/288507/3
authorayush.k123 <ayush.k123@samsung.com>
Fri, 17 Feb 2023 06:50:55 +0000 (12:20 +0530)
committerAyush Kumar <ayush.k123@samsung.com>
Fri, 17 Feb 2023 12:26:39 +0000 (12:26 +0000)
For better security, VD recommends using snprintf in place of sprintf.

Reference: https://review.tizen.org/gerrit/c/283371/

Change-Id: If615daf8f65d95f203ed856d8df4a1c87c9a8a7b
Signed-off-by: Ayush Kumar <ayush.k123@samsung.com>
tizen_src/ewk/ubrowser/logger.cc
tizen_src/ewk/ubrowser/window.cc

index 373619e..867f0f3 100644 (file)
@@ -80,7 +80,7 @@ _make_format(MESSAGE_TYPE type, int add_newline, const char* fmt) {
   if (msg_fmt == NULL) {
     return NULL;
   }
-  sprintf(msg_fmt, fmt_hdr, fmt);
+  snprintf(msg_fmt, fmt_len, fmt_hdr, fmt);
 
   if (add_newline) {
     msg_fmt[fmt_len - 2] = '\n';
index 56ad89b..28cd7c9 100644 (file)
@@ -872,7 +872,7 @@ void Window::OnScreenshotCaptured(Evas_Object* image, void* user_data) {
   log_trace("%s", __PRETTY_FUNCTION__);
   static int c = 1;
   char buf[250];
-  sprintf(buf, "screenshot%d.png", c++);
+  snprintf(buf, sizeof(buf), "screenshot%d.png", c++);
   if (evas_object_image_save(image, buf, 0, 0))
     log_info("Screenshot image saved in %s", buf);
   else