Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e761ac37 authored by Jerry Wong's avatar Jerry Wong Committed by Andreas Gampe
Browse files

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 bcb8747b)

Bug: 64160395
Test: m
Merged-In: If7b0f2a40f77bb5e5957c663999544f4ab2e69be
Change-Id: If7b0f2a40f77bb5e5957c663999544f4ab2e69be
parent 52c4582e
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -320,7 +320,8 @@ static int prepare_app_quota(const std::unique_ptr<std::string>& uuid, const std
        }

        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) {