aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2018-02-02 09:32:43 -0600
committerEric Sandeen <sandeen@redhat.com>2018-02-02 09:32:43 -0600
commit91c7d131631626eb701b149104aceae10ff1cb45 (patch)
tree303d892c5a36b1bf9e597e51f995ad6e8cac0d63
parent25f9772ab25ae1e35869ed71ecea951792e3fa10 (diff)
downloadxfsprogs-dev-91c7d131631626eb701b149104aceae10ff1cb45.tar.gz
mkfs: don't crash on dswidth overflow
I ran mkfs.xfs -d su=1048576,sw=$((18 * 1048576)), forgetting that sw takes a multiple of su (unlike swidth which takes any space unit). I was surprised when we hit a floating point exception, which I traced back to an integer overflow when we calculate swidth from dsw. So, do the 64-bit multiplication so we can detect the overflow and complain about it. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
-rw-r--r--mkfs/xfs_mkfs.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 5f1ac9fddf..7c9d148c02 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -2211,6 +2211,7 @@ calc_stripe_factors(
struct cli_params *cli,
struct fs_topology *ft)
{
+ long long int big_dswidth;
int dsunit = 0;
int dswidth = 0;
int lsunit = 0;
@@ -2251,7 +2252,14 @@ _("data su must be a multiple of the sector size (%d)\n"), cfg->sectorsize);
}
dsunit = (int)BTOBBT(dsu);
- dswidth = dsunit * dsw;
+ big_dswidth = (long long int)dsunit * dsw;
+ if (big_dswidth > INT_MAX) {
+ fprintf(stderr,
+_("data stripe width (%lld) is too large of a multiple of the data stripe unit (%d)\n"),
+ big_dswidth, dsunit);
+ usage();
+ }
+ dswidth = big_dswidth;
}
if (dsunit && (dswidth % dsunit != 0)) {