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

Commit 5a441fcf authored by Chenming Huang's avatar Chenming Huang Committed by Gabriel Biren
Browse files

Fix mul-overflow when converting scan result's age from ms to us

wifi_cached_scan_result's age_ms is a u32, which may cause
mul-overflow when multiplied by 1000. Fix this by explicitly
converting the type to u64 before doing multiplication.

Bug: 387187200
Test: m
Change-Id: Idaeb7bf5185b776cdeddb18c83f1b5b32e8b68a2
parent c96df1bc
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -3883,7 +3883,8 @@ bool convertCachedScanResultToAidl(const legacy_hal::wifi_cached_scan_result& le
        return false;
    }
    *aidl_scan_result = {};
    aidl_scan_result->timeStampInUs = ts_us - legacy_scan_result.age_ms * 1000;
    aidl_scan_result->timeStampInUs =
            ts_us - (static_cast<uint64_t>(legacy_scan_result.age_ms) * 1000);
    if (aidl_scan_result->timeStampInUs < 0) {
        aidl_scan_result->timeStampInUs = 0;
        return false;