From f77a6ec2ae90f5d58e9389e47228c18b081cf97a Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Thu, 12 Dec 2019 12:53:27 -0500 Subject: [PATCH] relayd: return invalid protocol error on close chunk disallowed clear MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Mathieu Desnoyers Change-Id: Ic10283d5a9769f01486d3f6df07f54a8d2856699 Signed-off-by: Jérémie Galarneau --- src/bin/lttng-relayd/main.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/bin/lttng-relayd/main.c b/src/bin/lttng-relayd/main.c index 5e99befa7..4e30ac498 100644 --- a/src/bin/lttng-relayd/main.c +++ b/src/bin/lttng-relayd/main.c @@ -2699,6 +2699,20 @@ static int relay_close_trace_chunk(const struct lttcomm_relayd_hdr *recv_hdr, } pthread_mutex_lock(&session->lock); + if (close_command.is_set && + close_command.value == LTTNG_TRACE_CHUNK_COMMAND_TYPE_DELETE) { + /* + * Clear command. It is a protocol error to ask for a + * clear on a relay which does not allow it. Querying + * the configuration allows figuring out whether + * clearing is allowed before doing the clear. + */ + if (!opt_allow_clear) { + ret = -1; + reply_code = LTTNG_ERR_INVALID_PROTOCOL; + goto end_unlock_session; + } + } if (session->pending_closure_trace_chunk && session->pending_closure_trace_chunk != chunk) { ERR("Trace chunk close command for session \"%s\" does not target the trace chunk pending closure", -- 2.34.1