svn commit: r332632 - head/usr.bin/quota
Conrad Meyer
cem at FreeBSD.org
Mon Apr 16 19:33:05 UTC 2018
Author: cem
Date: Mon Apr 16 19:33:04 2018
New Revision: 332632
URL: https://svnweb.freebsd.org/changeset/base/332632
Log:
quota(1): Fix calculation overflow and underflow
For very large quotas, do the multiplication as a 64 bit value to avoid
overflow.
For very small block sizes (smaller than DEV_BSIZE), multiple first
before dividing by block size to avoid underflow.
PR: 227496
Submitted by: Per Andersson <pa AT chalmers.se>
Sponsored by: Dell EMC Isilon
Modified:
head/usr.bin/quota/quota.c
Modified: head/usr.bin/quota/quota.c
==============================================================================
--- head/usr.bin/quota/quota.c Mon Apr 16 18:12:15 2018 (r332631)
+++ head/usr.bin/quota/quota.c Mon Apr 16 19:33:04 2018 (r332632)
@@ -621,14 +621,14 @@ getnfsquota(struct statfs *fst, struct quotause *qup,
gettimeofday(&tv, NULL);
/* blocks*/
dqp->dqb_bhardlimit =
- gq_rslt.getquota_rslt_u.gqr_rquota.rq_bhardlimit *
- (gq_rslt.getquota_rslt_u.gqr_rquota.rq_bsize / DEV_BSIZE);
+ ((uint64_t)gq_rslt.getquota_rslt_u.gqr_rquota.rq_bhardlimit *
+ gq_rslt.getquota_rslt_u.gqr_rquota.rq_bsize) / DEV_BSIZE;
dqp->dqb_bsoftlimit =
- gq_rslt.getquota_rslt_u.gqr_rquota.rq_bsoftlimit *
- (gq_rslt.getquota_rslt_u.gqr_rquota.rq_bsize / DEV_BSIZE);
+ ((uint64_t)gq_rslt.getquota_rslt_u.gqr_rquota.rq_bsoftlimit *
+ gq_rslt.getquota_rslt_u.gqr_rquota.rq_bsize) / DEV_BSIZE;
dqp->dqb_curblocks =
- gq_rslt.getquota_rslt_u.gqr_rquota.rq_curblocks *
- (gq_rslt.getquota_rslt_u.gqr_rquota.rq_bsize / DEV_BSIZE);
+ ((uint64_t)gq_rslt.getquota_rslt_u.gqr_rquota.rq_curblocks *
+ gq_rslt.getquota_rslt_u.gqr_rquota.rq_bsize) / DEV_BSIZE;
/* inodes */
dqp->dqb_ihardlimit =
gq_rslt.getquota_rslt_u.gqr_rquota.rq_fhardlimit;
More information about the svn-src-head
mailing list