projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix: Close socket handle on error
[lttng-tools.git]
/
src
/
bin
/
lttng-relayd
/
cmd-2-4.c
diff --git
a/src/bin/lttng-relayd/cmd-2-4.c
b/src/bin/lttng-relayd/cmd-2-4.c
index 45410e4e81ad912c8e7f45107ff59e50e6635f31..ac6e0425877970f3da91b05911fa8dc0c644609b 100644
(file)
--- a/
src/bin/lttng-relayd/cmd-2-4.c
+++ b/
src/bin/lttng-relayd/cmd-2-4.c
@@
-1,6
+1,7
@@
/*
* Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com>
* David Goulet <dgoulet@efficios.com>
/*
* Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com>
* David Goulet <dgoulet@efficios.com>
+ * 2015 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License, version 2 only, as
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License, version 2 only, as
@@
-16,36
+17,54
@@
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#define _
GNU
_SOURCE
+#define _
LGPL
_SOURCE
#include <assert.h>
#include <assert.h>
-#include <string.h>
#include <common/common.h>
#include <common/sessiond-comm/relayd.h>
#include <common/common.h>
#include <common/sessiond-comm/relayd.h>
-#include "cmd-generic.h"
+#include <common/compat/endian.h>
+#include <common/compat/string.h>
+#include <lttng/constant.h>
+
+#include "cmd-2-4.h"
#include "lttng-relayd.h"
#include "lttng-relayd.h"
-int cmd_create_session_2_4(struct relay_command *cmd,
- struct relay_session *session)
+int cmd_create_session_2_4(const struct lttng_buffer_view *payload,
+ char *session_name, char *hostname,
+ uint32_t *live_timer, bool *snapshot)
{
int ret;
struct lttcomm_relayd_create_session_2_4 session_info;
{
int ret;
struct lttcomm_relayd_create_session_2_4 session_info;
+ size_t len;
+
+ if (payload->size < sizeof(session_info)) {
+ ERR("Unexpected payload size in \"cmd_create_session_2_4\": expected >= %zu bytes, got %zu bytes",
+ sizeof(session_info), payload->size);
+ ret = -1;
+ goto error;
+ }
+ memcpy(&session_info, payload->data, sizeof(session_info));
- assert(cmd);
- assert(session);
+ len = lttng_strnlen(session_info.session_name, sizeof(session_info.session_name));
+ /* Ensure that NULL-terminated and fits in local filename length. */
+ if (len == sizeof(session_info.session_name) || len >= LTTNG_NAME_MAX) {
+ ret = -ENAMETOOLONG;
+ ERR("Session name too long");
+ goto error;
+ }
+ strncpy(session_name, session_info.session_name, LTTNG_PATH_MAX);
- ret = cmd_recv(cmd->sock, &session_info, sizeof(session_info));
- if (ret < 0) {
- ERR("Unable to recv session info version 2.4");
+ 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;
}
goto error;
}
+ strncpy(hostname, session_info.hostname, LTTNG_HOST_NAME_MAX);
- 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);
+ *live_timer = be32toh(session_info.live_timer);
+ *snapshot = be32toh(session_info.snapshot);
ret = 0;
ret = 0;
This page took
0.027525 seconds
and
5
git commands to generate.