From d3faab47a5ff8be82a1a1df16483d1666f21d3a6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Sun, 15 Sep 2019 14:56:23 -0400 Subject: [PATCH] kconsumer: clean-up: initialize ctf_index before populating it MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The 'offset' field of the ctf_index is used uninitialized when it is populated. Its uninitialized value is read and stored back. This is not a problem as the offset is populated later-on. Coveity reports 1405630 Uninitialized scalar variable The variable will contain an arbitrary value left from earlier computations. In lttng_kconsumer_read_subbuffer: Use of an uninitialized variable (CWE-457) Reported-by: Coverity Scan Signed-off-by: Jérémie Galarneau --- src/common/kernel-consumer/kernel-consumer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/kernel-consumer/kernel-consumer.c b/src/common/kernel-consumer/kernel-consumer.c index aea1b4831..9fa92f6b8 100644 --- a/src/common/kernel-consumer/kernel-consumer.c +++ b/src/common/kernel-consumer/kernel-consumer.c @@ -1553,7 +1553,7 @@ ssize_t lttng_kconsumer_read_subbuffer(struct lttng_consumer_stream *stream, int err, write_index = 1, rotation_ret; ssize_t ret = 0; int infd = stream->wait_fd; - struct ctf_packet_index index; + struct ctf_packet_index index = {}; DBG("In read_subbuffer (infd : %d)", infd); -- 2.34.1