mdadm/0003-Grow-avoid-overflow-in-compute_backup_blocks.patch
Zhiqiang Liu 0c2f4fd8eb mdadm: renumber patches
patches number counts from 6000. We renumber patches from 0.

Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
2020-06-29 22:06:27 +08:00

31 lines
882 B
Diff

From b3d9d18abdf2c7963bb8bfcdd402cdb717c6b3a2 Mon Sep 17 00:00:00 2001
From: root <root@localhost.localdomain>
Date: Wed, 10 Apr 2019 21:40:46 +0800
Subject: [PATCH 4/6] Grow: avoid overflow in compute_backup_blocks()
With a chunk size of 16Meg and data drive count of 8,
this calculate can easily overflow the 'int' type that
is used for the multiplications.
So force it to use "long" instead.
---
Grow.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Grow.c b/Grow.c
index 4436a4d..76f82c0 100644
--- a/Grow.c
+++ b/Grow.c
@@ -1196,7 +1196,8 @@ unsigned long compute_backup_blocks(int nchunk, int ochunk,
/* Find GCD */
a = GCD(a, b);
/* LCM == product / GCD */
- blocks = (ochunk/512) * (nchunk/512) * odata * ndata / a;
+ blocks = (unsigned long)(ochunk/512) * (unsigned long)(nchunk/512) *
+ odata * ndata / a;
return blocks;
}
--
2.19.1