Fix: consumer snapshot: handle unsigned long overflow
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 19 Feb 2019 22:47:49 +0000 (17:47 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 29 Mar 2019 16:00:44 +0000 (12:00 -0400)
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 <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/common/kernel-consumer/kernel-consumer.c
src/common/ust-consumer/ust-consumer.c

index ccca69e0eaded03676acf8278ac30413991b6bbc..22f18c157585ff550887563962a4f4f3f58b7ec0 100644 (file)
@@ -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;
 
index baa81d450aae793b084d2450450d0f793b7b9d20..071276042a443297560b734ef4cf276f517aab25 100644 (file)
@@ -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;
 
This page took 0.027291 seconds and 4 git commands to generate.