Fix: session's hostname wrongly assigned
authorDavid Goulet <dgoulet@efficios.com>
Mon, 30 Sep 2013 17:19:01 +0000 (13:19 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Mon, 30 Sep 2013 17:23:49 +0000 (13:23 -0400)
Signed-off-by: David Goulet <dgoulet@efficios.com>
src/bin/lttng-sessiond/session.c
src/bin/lttng-sessiond/session.h

index e4c747f7fd8e54583815ccb199e926aae226c611..07031a30a5c5bc6cf603b84847aac2a866919ede 100644 (file)
@@ -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 */
index de98bde514f4e62d56984faa455d7905f1dd3325..e052d6d337e10ee69490df9df9181962bd01b248 100644 (file)
@@ -18,6 +18,7 @@
 #ifndef _LTT_SESSION_H
 #define _LTT_SESSION_H
 
+#include <limits.h>
 #include <urcu/list.h>
 
 #include <common/hashtable/hashtable.h>
@@ -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;
        /*
This page took 0.026901 seconds and 5 git commands to generate.