Installd: Fix math overflow on quota calculation
On 32-bit devices, the hard quota size calculation could overflow that
would cause the hard quota limit size to be much lower than intended.
b/64160395
(cherry picked from commit bcb8747bcb6ab45dfefc425ca6889ebf02ae5f26)
Bug: 64160395
Test: m
Merged-In: If7b0f2a40f77bb5e5957c663999544f4ab2e69be
Change-Id: If7b0f2a40f77bb5e5957c663999544f4ab2e69be
diff --git a/cmds/installd/InstalldNativeService.cpp b/cmds/installd/InstalldNativeService.cpp
index 033a714..054c88e 100644
--- a/cmds/installd/InstalldNativeService.cpp
+++ b/cmds/installd/InstalldNativeService.cpp
@@ -320,7 +320,8 @@
}
dq.dqb_valid = QIF_LIMITS;
- dq.dqb_bhardlimit = (((stat.f_blocks * stat.f_frsize) / 10) * 9) / QIF_DQBLKSIZE;
+ dq.dqb_bhardlimit =
+ (((static_cast<uint64_t>(stat.f_blocks) * stat.f_frsize) / 10) * 9) / QIF_DQBLKSIZE;
dq.dqb_ihardlimit = (stat.f_files / 2);
if (quotactl(QCMD(Q_SETQUOTA, USRQUOTA), device.c_str(), uid,
reinterpret_cast<char*>(&dq)) != 0) {