From 247e5c4422c70a122e0a3060f1a884c56ed3c065 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Tue, 19 Feb 2019 17:47:49 -0500 Subject: [PATCH] Fix: consumer snapshot: handle unsigned long overflow MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Comparing the consumed iterator and the produced position without using a difference generates an empty snapshot when the iterator is before unsigned long overflow and the produced position is after unsigned long overflow. This applies to both UST and kernel consumers. Signed-off-by: Mathieu Desnoyers Signed-off-by: Jérémie Galarneau --- src/common/kernel-consumer/kernel-consumer.c | 2 +- src/common/ust-consumer/ust-consumer.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/kernel-consumer/kernel-consumer.c b/src/common/kernel-consumer/kernel-consumer.c index ccca69e0e..22f18c157 100644 --- a/src/common/kernel-consumer/kernel-consumer.c +++ b/src/common/kernel-consumer/kernel-consumer.c @@ -235,7 +235,7 @@ int lttng_kconsumer_snapshot_channel(uint64_t key, char *path, produced_pos, nb_packets_per_stream, stream->max_sb_size); - while (consumed_pos < produced_pos) { + while ((long) (consumed_pos - produced_pos) < 0) { ssize_t read_len; unsigned long len, padded_len; diff --git a/src/common/ust-consumer/ust-consumer.c b/src/common/ust-consumer/ust-consumer.c index baa81d450..071276042 100644 --- a/src/common/ust-consumer/ust-consumer.c +++ b/src/common/ust-consumer/ust-consumer.c @@ -1180,7 +1180,7 @@ static int snapshot_channel(uint64_t key, char *path, uint64_t relayd_id, produced_pos, nb_packets_per_stream, stream->max_sb_size); - while (consumed_pos < produced_pos) { + while ((long) (consumed_pos - produced_pos) < 0) { ssize_t read_len; unsigned long len, padded_len; -- 2.34.1