From: David Goulet Date: Mon, 30 Sep 2013 17:19:01 +0000 (-0400) Subject: Fix: session's hostname wrongly assigned X-Git-Tag: v2.4.0-rc1~127 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=731848356e38d33b32fc6346ac30fba3a46a8673;p=lttng-tools.git Fix: session's hostname wrongly assigned Signed-off-by: David Goulet --- diff --git a/src/bin/lttng-sessiond/session.c b/src/bin/lttng-sessiond/session.c index e4c747f7f..07031a30a 100644 --- a/src/bin/lttng-sessiond/session.c +++ b/src/bin/lttng-sessiond/session.c @@ -195,8 +195,13 @@ int session_create(char *name, uid_t uid, gid_t gid) } ret = gethostname(new_session->hostname, sizeof(new_session->hostname)); - if (ret && errno == ENAMETOOLONG) { - new_session->hostname[HOST_NAME_MAX - 1] = '\0'; + if (ret < 0) { + if (errno == ENAMETOOLONG) { + new_session->hostname[sizeof(new_session->hostname) - 1] = '\0'; + } else { + ret = LTTNG_ERR_FATAL; + goto error; + } } /* Init kernel session */ diff --git a/src/bin/lttng-sessiond/session.h b/src/bin/lttng-sessiond/session.h index de98bde51..e052d6d33 100644 --- a/src/bin/lttng-sessiond/session.h +++ b/src/bin/lttng-sessiond/session.h @@ -18,6 +18,7 @@ #ifndef _LTT_SESSION_H #define _LTT_SESSION_H +#include #include #include @@ -59,8 +60,7 @@ struct ltt_session_list { */ struct ltt_session { char name[NAME_MAX]; - /* FIXME : size */ - char hostname[PATH_MAX]; /* local hostname, FIXME : could be useful to have that user defined too */ + char hostname[HOST_NAME_MAX]; /* Local hostname. */ struct ltt_kernel_session *kernel_session; struct ltt_ust_session *ust_session; /*