mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
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
This commit is contained in:
parent
52c0983128
commit
404d2fee56
1 changed files with 6 additions and 6 deletions
|
|
@ -621,14 +621,14 @@ getnfsquota(struct statfs *fst, struct quotause *qup, long id, int quotatype)
|
|||
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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue