- strncpy(session->session_name, session_info.session_name,
- sizeof(session->session_name));
- strncpy(session->hostname, session_info.hostname,
- sizeof(session->hostname));
- session->live_timer = be32toh(session_info.live_timer);
+ len = lttng_strnlen(session_info.hostname, sizeof(session_info.hostname));
+ if (len == sizeof(session_info.hostname) || len >= LTTNG_HOST_NAME_MAX) {
+ ret = -ENAMETOOLONG;
+ ERR("Session name too long");
+ goto error;
+ }
+ strncpy(hostname, session_info.hostname,
+ sizeof(session_info.hostname));
+ *live_timer = be32toh(session_info.live_timer);
+ *snapshot = be32toh(session_info.snapshot);