[PATCH] ivi-controller: fixed string copy in controller_screen_screenshot

Natsume, Wataru (ADITJ/SWG) wnatsume at jp.adit-jv.com
Wed Mar 30 03:39:39 EDT 2016

Hello Potrola-san,

Thank you so much for the patch.
It looks fine with me. If any concern comes from other guys, I will push it to master.

Best Regards,
Wataru Natsume

Wataru Natsume / 夏目 亘
Advanced Driver Information Technology
Software Group (ADITJ/SWG)
E-mail: wnatsume at jp.adit-jv.com
Tel: +81-(0)566-61-4551 / Extension 551-43644

-----Original Message-----
From: genivi-ivi-layer-management-bounces at lists.genivi.org [mailto:genivi-ivi-layer-management-bounces at lists.genivi.org] On Behalf Of mateuszx.potrola at intel.com
Sent: Tuesday, March 29, 2016 6:59 PM
To: genivi-ivi-layer-management at lists.genivi.org
Subject: [PATCH] ivi-controller: fixed string copy in controller_screen_screenshot

From: Mateusz Polrola <mateuszx.potrola at intel.com>

With earlier implementation memory for NULL byte of l->filename string was not being allocated by malloc (strlen is returning length of string without NULL terminating byte) which may result in some random characters appended in filename string.
Now strdup is begin used for string copy instead of malloc/strcpy.

Signed-off-by: Mateusz Polrola <mateuszx.potrola at intel.com>
 weston-ivi-shell/src/ivi-controller-impl.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/weston-ivi-shell/src/ivi-controller-impl.c b/weston-ivi-shell/src/ivi-controller-impl.c
index 5fa78aa..15e677e 100644
--- a/weston-ivi-shell/src/ivi-controller-impl.c
+++ b/weston-ivi-shell/src/ivi-controller-impl.c
@@ -917,7 +917,7 @@ controller_screen_screenshot(struct wl_client *client,
-    l->filename = malloc(strlen(filename));
+    l->filename = strdup(filename);
     if(l->filename == NULL) {
         fprintf(stderr, "fails to allocate memory\n");
@@ -925,7 +925,6 @@ controller_screen_screenshot(struct wl_client *client,
     output = ivi_extension_screen_get_output(iviscrn->shell, iviscrn->layout_screen);
-    strcpy(l->filename, filename);
     l->listener.notify = controller_screenshot_notify;
     wl_signal_add(&output->frame_signal, &l->listener);

Intel Research and Development Ireland Limited Registered in Ireland Registered Office: Collinstown Industrial Park, Leixlip, County Kildare Registered Number: 308263

This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.

genivi-ivi-layer-management mailing list genivi-ivi-layer-management at lists.genivi.org

More information about the genivi-ivi-layer-management mailing list