From 301c2b8822f212c2dba462dd7390bbab03ebc823 Mon Sep 17 00:00:00 2001 From: Milan Broz Date: Wed, 2 Mar 2011 16:56:06 +0000 Subject: [PATCH] Use 64bit unsigned value for maximum stripe size test. While STRIPE_SIZE_LIMIT * 2 is basically UINT_MAX, 32bit integer value can already overflow durin arg size parsing. (This really happens in test where --stripesize 4294967291 is used, in s390x uint overflow and this test is ineffective.) --- WHATS_NEW | 1 + tools/lvresize.c | 2 +- tools/toollib.c | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index e1e5feeb6..19cb9ae75 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.85 - =================================== + Fix possible overwlow in maximum stripe size. Add test for failed allocation from dm_task_set_uuid() in dmeventd. Improve pvremove error message when PV belongs to a VG. Extend normal policy to allow mirror logs on same PVs as images if necessary. diff --git a/tools/lvresize.c b/tools/lvresize.c index 225c4465b..5a9b8fa44 100644 --- a/tools/lvresize.c +++ b/tools/lvresize.c @@ -55,7 +55,7 @@ static int _validate_stripesize(struct cmd_context *cmd, return 0; } - if (arg_uint_value(cmd, stripesize_ARG, 0) > STRIPE_SIZE_LIMIT * 2) { + if (arg_uint64_value(cmd, stripesize_ARG, 0) > STRIPE_SIZE_LIMIT * 2) { log_error("Stripe size cannot be larger than %s", display_size(cmd, (uint64_t) STRIPE_SIZE_LIMIT)); return 0; diff --git a/tools/toollib.c b/tools/toollib.c index cdd8bb752..b9019b8d4 100644 --- a/tools/toollib.c +++ b/tools/toollib.c @@ -1541,7 +1541,7 @@ int get_stripe_params(struct cmd_context *cmd, uint32_t *stripes, uint32_t *stri return 0; } - if(*stripe_size > STRIPE_SIZE_LIMIT * 2) { + if(arg_uint64_value(cmd, stripesize_ARG, 0) > STRIPE_SIZE_LIMIT * 2) { log_error("Stripe size cannot be larger than %s", display_size(cmd, (uint64_t) STRIPE_SIZE_LIMIT)); return 0; -- 2.43.5