From 36a56e98fb208683888c8c1bf9fcf49008610dfd Mon Sep 17 00:00:00 2001 From: Mateusz Polrola Date: Thu, 31 Mar 2016 20:15:27 +0900 Subject: ivi-controller: fixed string copy in controller_screen_screenshot 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 --- 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, return; } - l->filename = malloc(strlen(filename)); + l->filename = strdup(filename); if(l->filename == NULL) { fprintf(stderr, "fails to allocate memory\n"); free(l); @@ -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); output->disable_planes++; -- cgit v1.2.1