From 731848356e38d33b32fc6346ac30fba3a46a8673 Mon Sep 17 00:00:00 2001 From: David Goulet Date: Mon, 30 Sep 2013 13:19:01 -0400 Subject: [PATCH] Fix: session's hostname wrongly assigned Signed-off-by: David Goulet --- src/bin/lttng-sessiond/session.c | 9 +++++++-- src/bin/lttng-sessiond/session.h | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) 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; /* -- 2.34.1