From ea9ab2dd5a8026740a27ac726c8ca09b348dbf78 Mon Sep 17 00:00:00 2001 From: "Carsten Haitzler (Rasterman)" Date: Tue, 6 Nov 2018 16:52:01 +0000 Subject: [PATCH] eina debug - fix buffer truncation warning make buf the size of the unix socket path to truncate early to avoid warning --- src/lib/eina/eina_debug.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib/eina/eina_debug.c b/src/lib/eina/eina_debug.c index 4d003bf029..d46b18bb00 100644 --- a/src/lib/eina/eina_debug.c +++ b/src/lib/eina/eina_debug.c @@ -496,9 +496,9 @@ EAPI Eina_Debug_Session * eina_debug_local_connect(Eina_Bool is_master) { #ifndef _WIN32 - char buf[4096]; int fd, socket_unix_len, curstate = 0; struct sockaddr_un socket_unix; + char buf[sizeof(socket_unix.sun_path)]; if (is_master) return eina_debug_remote_connect(REMOTE_SERVER_PORT); @@ -520,7 +520,8 @@ eina_debug_local_connect(Eina_Bool is_master) // sa that it's a unix socket and where the path is memset(&socket_unix, 0, sizeof(socket_unix)); socket_unix.sun_family = AF_UNIX; - strncpy(socket_unix.sun_path, buf, sizeof(socket_unix.sun_path) - 1); + strncpy(socket_unix.sun_path, buf, sizeof(socket_unix.sun_path)); + socket_unix.sun_path[sizeof(socket_unix.sun_path) - 1] = 0; socket_unix_len = LENGTH_OF_SOCKADDR_UN(&socket_unix); // actually connect to efl_debugd service if (connect(fd, (struct sockaddr *)&socket_unix, socket_unix_len) < 0)