From: Jérémie Galarneau Date: Wed, 11 Sep 2019 00:35:19 +0000 (-0400) Subject: Fix: dereference of NULL pointer in stream_write() X-Git-Tag: v2.12.0-rc1~403 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=014e956d14322163d9740bb6f35580f21358f702;p=lttng-tools.git Fix: dereference of NULL pointer in stream_write() stream_write() can be used with a NULL packet to write padding only to a stream. In the case of a metadata stream, packet is assumed to always be non-NULL which may not always be true. Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-relayd/stream.c b/src/bin/lttng-relayd/stream.c index c02820d31..f98b46557 100644 --- a/src/bin/lttng-relayd/stream.c +++ b/src/bin/lttng-relayd/stream.c @@ -1015,7 +1015,8 @@ int stream_write(struct relay_stream *stream, } if (stream->is_metadata) { - stream->metadata_received += packet->size + padding_len; + stream->metadata_received += packet ? packet->size : 0; + stream->metadata_received += padding_len; } DBG("Wrote to %sstream %" PRIu64 ": data_length = %zu, padding_length = %zu",