]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Grow: avoid truncation error when checking size of array.
authorNeilBrown <neilb@suse.de>
Thu, 26 Nov 2009 03:19:26 +0000 (14:19 +1100)
committerNeilBrown <neilb@suse.de>
Thu, 26 Nov 2009 03:19:26 +0000 (14:19 +1100)
array.size is only 32bit so it is not safe to multiply it
up before casting to (long long).
Actually, we shouldn't be using array.size here at all, but that
will get fixed in a subsequent patch.

Reported-by: Andrew Burgess <aab@cichlid.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Grow.c

diff --git a/Grow.c b/Grow.c
index 7764bdb6275d728ea5826593b3f8158aabb74f19..a654d4e84f2aba2571797e11698772bc53d50535 100644 (file)
--- a/Grow.c
+++ b/Grow.c
@@ -891,7 +891,7 @@ int Grow_reshape(char *devname, int fd, int quiet, char *backup_file,
                }
 
                /* Check that we can hold all the data */
-               size = ndata * array.size;
+               size = ndata * (long long)array.size;
                get_dev_size(fd, NULL, &array_size);
                if (size < (array_size/1024)) {
                        fprintf(stderr, Name ": this change will reduce the size of the array.\n"