From: David Goulet Date: Mon, 4 Nov 2013 19:17:20 +0000 (-0500) Subject: Fix: don't enable if param overflows when rounded up X-Git-Tag: v2.4.0-rc1~83 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=06c0da969b6b69e68029df1db6e625a409cb989f;p=lttng-tools.git Fix: don't enable if param overflows when rounded up Fixes #641 Signed-off-by: David Goulet --- diff --git a/src/bin/lttng/commands/enable_channels.c b/src/bin/lttng/commands/enable_channels.c index 18f8d020e..b59c05861 100644 --- a/src/bin/lttng/commands/enable_channels.c +++ b/src/bin/lttng/commands/enable_channels.c @@ -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);