eina debug - fix buffer truncation warning
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>
Tue, 6 Nov 2018 16:52:01 +0000 (16:52 +0000)
committerSangHyeon Jade Lee <sh10233.lee@samsung.com>
Tue, 20 Nov 2018 06:56:20 +0000 (15:56 +0900)
make buf the size of the unix socket path to truncate early to avoid
warning

src/lib/eina/eina_debug.c

index a042102..2eef1ae 100644 (file)
@@ -499,9 +499,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);
 
@@ -523,7 +523,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)