Fix: don't enable if param overflows when rounded up
authorDavid Goulet <dgoulet@efficios.com>
Mon, 4 Nov 2013 19:17:20 +0000 (14:17 -0500)
committerDavid Goulet <dgoulet@efficios.com>
Mon, 4 Nov 2013 19:38:38 +0000 (14:38 -0500)
Fixes #641

Signed-off-by: David Goulet <dgoulet@efficios.com>
src/bin/lttng/commands/enable_channels.c

index 18f8d020eef5089ef4309ec9608a3ebd5589fcd7..b59c05861beeb021b0c1327def90381fe21378a4 100644 (file)
@@ -356,6 +356,13 @@ int cmd_enable_channels(int argc, const char **argv)
                        order = get_count_order_u64(chan.attr.subbuf_size);
                        assert(order >= 0);
                        rounded_size = 1ULL << order;
+                       if (rounded_size < chan.attr.subbuf_size) {
+                               ERR("The subbuf size (%" PRIu64 ") is rounded and overflows!",
+                                               chan.attr.subbuf_size);
+                               ret = CMD_ERROR;
+                               goto end;
+                       }
+
                        if (rounded_size != chan.attr.subbuf_size) {
                                WARN("The subbuf size (%" PRIu64 ") is rounded to the next power of 2 (%" PRIu64 ")",
                                                chan.attr.subbuf_size, rounded_size);
@@ -385,6 +392,13 @@ int cmd_enable_channels(int argc, const char **argv)
                        order = get_count_order_u64(chan.attr.num_subbuf);
                        assert(order >= 0);
                        rounded_size = 1ULL << order;
+                       if (rounded_size < chan.attr.subbuf_size) {
+                               ERR("The number of subbuffers (%" PRIu64 ") is rounded and overflows!",
+                                               chan.attr.num_subbuf);
+                               ret = CMD_ERROR;
+                               goto end;
+                       }
+
                        if (rounded_size != chan.attr.num_subbuf) {
                                WARN("The number of subbuffers (%" PRIu64 ") is rounded to the next power of 2 (%" PRIu64 ")",
                                                chan.attr.num_subbuf, rounded_size);
This page took 0.025756 seconds and 4 git commands to generate.