]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Grow: fix resize of array component size to > 32bits
authorJustin Maggard <jmaggard10@gmail.com>
Sat, 25 Oct 2014 00:55:02 +0000 (17:55 -0700)
committerNeilBrown <neilb@suse.de>
Wed, 29 Oct 2014 00:03:09 +0000 (11:03 +1100)
If the request --size to --grow an array to is larger
than 32bits, then mdadm may make the wrong choice and
use ioctl instead of setting component_size via sysfs
and the change is ignored.

Instead of using casts to check for a 32-bit overflow,
just check for set bits outside of INT32_MAX.

Fixes: 4e9a3dd16d656b269f5602624ac4f7109a571368
Signed-off-by: NeilBrown <neilb@suse.de>
Grow.c

diff --git a/Grow.c b/Grow.c
index 76bb35a862164a7f887f3a149b2d35e326f2ebfe..a0f7526e93f588540be311d2290ac1ac7c051efc 100644 (file)
--- a/Grow.c
+++ b/Grow.c
@@ -1818,7 +1818,7 @@ int Grow_reshape(char *devname, int fd,
                if (s->size == MAX_SIZE)
                        s->size = 0;
                array.size = s->size;
-               if (array.size != (signed)s->size) {
+               if (s->size & ~INT32_MAX) {
                        /* got truncated to 32bit, write to
                         * component_size instead
                         */