From 67e3bbc7f6f7c027e23921f577040c1bcb478802 Mon Sep 17 00:00:00 2001 From: Yi-Yo Chiang Date: Fri, 12 Feb 2021 15:55:50 +0800 Subject: [PATCH] Explicitly cast to 64bit integer when calculating filesystem size Else the result may overflow on platforms that have 32bit long. Bug: 165925766 Test: Presubmit Change-Id: I3018f0bd9846651848bd9b3645f2eeaa5b61c646 --- fs_mgr/fs_mgr_overlayfs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs_mgr/fs_mgr_overlayfs.cpp b/fs_mgr/fs_mgr_overlayfs.cpp index cdbadc9cd..1134f149b 100644 --- a/fs_mgr/fs_mgr_overlayfs.cpp +++ b/fs_mgr/fs_mgr_overlayfs.cpp @@ -194,7 +194,7 @@ bool fs_mgr_filesystem_has_space(const std::string& mount_point) { static constexpr unsigned long kSizeThreshold = 8 * 1024 * 1024; // 8MB return (vst.f_bfree >= (vst.f_blocks * kPercentThreshold / 100)) && - (vst.f_bfree * vst.f_bsize) >= kSizeThreshold; + (static_cast(vst.f_bfree) * vst.f_frsize) >= kSizeThreshold; } const auto kPhysicalDevice = "/dev/block/by-name/"s;