X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=liblttngctl%2Fliblttngctl.c;h=ec01859a9aa00b3394f6bfe29ac89abbfb976ae6;hp=2464bce3b2d1eb30ab0252a2fc4f224a5a85b0c0;hb=ca3c5ac0cf100d80352a1a81936b5adc47942f35;hpb=7d8234d9e6f162ee642cdbec911f46c29b012c3d diff --git a/liblttngctl/liblttngctl.c b/liblttngctl/liblttngctl.c index 2464bce3b..ec01859a9 100644 --- a/liblttngctl/liblttngctl.c +++ b/liblttngctl/liblttngctl.c @@ -30,7 +30,7 @@ #include -#include "liblttsessiondcomm.h" +#include #include "lttngerr.h" #include "lttng-share.h" @@ -46,6 +46,18 @@ static struct lttcomm_lttng_msg llm; static char *tracing_group; static int connected; +/* + * Copy string from src to dst and enforce null terminated byte. + */ +static void copy_string(char *dst, const char *src, size_t len) +{ + if (src && dst) { + strncpy(dst, src, len); + /* Enforce the NULL terminated byte */ + dst[len - 1] = '\0'; + } +} + /* * send_data_sessiond * @@ -154,13 +166,14 @@ static int set_session_daemon_path(void) /* Are we in the tracing group ? */ ret = check_tracing_group(tracing_group); if (ret < 0 && getuid() != 0) { - if (sprintf(sessiond_sock_path, DEFAULT_HOME_CLIENT_UNIX_SOCK, - getenv("HOME")) < 0) { + if (snprintf(sessiond_sock_path, PATH_MAX, + DEFAULT_HOME_CLIENT_UNIX_SOCK, + getenv("HOME")) < 0) { return -ENOMEM; } } else { - strncpy(sessiond_sock_path, DEFAULT_GLOBAL_CLIENT_UNIX_SOCK, - sizeof(DEFAULT_GLOBAL_CLIENT_UNIX_SOCK)); + copy_string(sessiond_sock_path, DEFAULT_GLOBAL_CLIENT_UNIX_SOCK, + PATH_MAX); } return 0; @@ -300,18 +313,6 @@ static void copy_lttng_domain(struct lttng_domain *dom) } } -/* - * Copy string from src to dst and enforce null terminated byte. - */ -static void copy_string(char *dst, const char *src, size_t len) -{ - if (src && dst) { - strncpy(dst, src, len); - /* Enforce the NULL terminated byte */ - dst[len - 1] = '\0'; - } -} - /* * Start tracing for all trace of the session. */