ecore_con: add '\0' termination to path.

Summary:
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.

Signed-off-by: Prateek Thakur <prateek.th@samsung.com>

Reviewers: cedric, thiepha

Subscribers: jpeg

Differential Revision: https://phab.enlightenment.org/D4247

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
This commit is contained in:
Prateek Thakur 2016-08-19 16:12:41 -07:00 committed by Cedric BAIL
parent d8cab9347a
commit 9348a84aa0
1 changed files with 4 additions and 2 deletions

View File

@ -170,7 +170,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);
}
@ -330,7 +331,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);
}