From 171a558b1b7699dc5bcfbaff6de552dbc01668ae Mon Sep 17 00:00:00 2001 From: Prateek Thakur Date: Fri, 5 Aug 2016 14:38:13 +0530 Subject: [PATCH] ecore_con_local: Add NULL termination Copying from string 'buf' of length 4095 to '&socket_unix.sun_path[0]' may form a non-terminated C string of size 108. So added null termination. Change-Id: Icdd2cd4eaf213852196cf551ee7d3ef5a252f8ee Signed-off-by: Prateek Thakur --- src/lib/ecore_con/ecore_con_local.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) mode change 100644 => 100755 src/lib/ecore_con/ecore_con_local.c diff --git a/src/lib/ecore_con/ecore_con_local.c b/src/lib/ecore_con/ecore_con_local.c old mode 100644 new mode 100755 index dc81334..cadd551 --- a/src/lib/ecore_con/ecore_con_local.c +++ b/src/lib/ecore_con/ecore_con_local.c @@ -259,7 +259,8 @@ ecore_con_local_connect(Ecore_Con_Server *obj, } else { - strncpy(socket_unix.sun_path, buf, sizeof(socket_unix.sun_path)); + strncpy(socket_unix.sun_path, buf, sizeof(socket_unix.sun_path) - 1); + socket_unix.sun_path[sizeof(socket_unix.sun_path) - 1] = '\0'; socket_unix_len = LENGTH_OF_SOCKADDR_UN(&socket_unix); } @@ -419,7 +420,8 @@ start: else { abstract_socket = EINA_FALSE; - strncpy(socket_unix.sun_path, buf, sizeof(socket_unix.sun_path)); + strncpy(socket_unix.sun_path, buf, sizeof(socket_unix.sun_path) - 1); + socket_unix.sun_path[sizeof(socket_unix.sun_path) - 1] = '\0'; socket_unix_len = LENGTH_OF_SOCKADDR_UN(&socket_unix); } -- 2.7.4