Bug 221697

Summary: /usr/bin/quota incorrectly calculates NFS quota values.
Product: Base System Reporter: Stephen Usher <stephen.usher>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed DUPLICATE    
Severity: Affects Many People CC: cem
Priority: --- Keywords: patch
Version: 11.1-STABLE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
Patch to correct quota.c NFS calculation.
none
Better and safer patch none

Description Stephen Usher 2017-08-21 16:41:46 UTC
Created attachment 185644 [details]
Patch to correct quota.c NFS calculation.

quota(1) incorrectly reports zero values to NFS quotas due to incorrect arithmetic causing underflow to zero of unsigned integer values.
Comment 1 Stephen Usher 2017-08-21 18:32:31 UTC
Created attachment 185645 [details]
Better and safer patch

Here's a better (and far safer) patch which works if the reported bsize is either smaller or larger than DEV_BSIZE.

The original bug caused the calculation of the scaling factor to underflow to zero is the reported bsize was smaller than DEV_BSIZE.
Comment 2 Conrad Meyer freebsd_committer freebsd_triage 2018-04-16 19:35:29 UTC
Obviated by r332632 / PR 227496.  The patch in comment #1 is incorrect for quota64.  The 32-bit return value truncates a 64-bit result.

*** This bug has been marked as a duplicate of bug 227496 ***