X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=liblttsessiondcomm%2Fliblttsessiondcomm.c;h=cecd89d6a5815fc7ee1e472821474afc4785dc39;hp=29678240106b55182b98d73d1ba8122a70dc281f;hb=fc2c5c882c8b0eec3ecca145add12b30ce2c5fdf;hpb=773168b7255d45fd28f018055292e93b7a76482d diff --git a/liblttsessiondcomm/liblttsessiondcomm.c b/liblttsessiondcomm/liblttsessiondcomm.c index 296782401..cecd89d6a 100644 --- a/liblttsessiondcomm/liblttsessiondcomm.c +++ b/liblttsessiondcomm/liblttsessiondcomm.c @@ -127,6 +127,7 @@ int lttcomm_connect_unix_sock(const char *pathname) memset(&sun, 0, sizeof(sun)); sun.sun_family = AF_UNIX; strncpy(sun.sun_path, pathname, sizeof(sun.sun_path)); + sun.sun_path[sizeof(sun.sun_path) - 1] = '\0'; ret = connect(fd, (struct sockaddr *) &sun, sizeof(sun)); if (ret < 0) { @@ -191,7 +192,8 @@ int lttcomm_create_unix_sock(const char *pathname) memset(&sun, 0, sizeof(sun)); sun.sun_family = AF_UNIX; - strncpy(sun.sun_path, pathname, strlen(pathname)); + strncpy(sun.sun_path, pathname, sizeof(sun.sun_path)); + sun.sun_path[sizeof(sun.sun_path) - 1] = '\0'; /* Unlink the old file if present */ (void) unlink(pathname);