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.11.0-rc4~56 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=e0e4d1964e1f3eba13c28b1300c5c77833d1fbee;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",