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

Commit 2ea5b4b5 authored by Gabriel Biren's avatar Gabriel Biren Committed by Android (Google) Code Review
Browse files

Merge "Fix sub-underfow when converting scan result's age from ms to us" into main

parents 8faadf3a e793f836
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -3895,12 +3895,13 @@ bool convertCachedScanResultToAidl(const legacy_hal::wifi_cached_scan_result& le
        return false;
    }
    *aidl_scan_result = {};
    aidl_scan_result->timeStampInUs =
            ts_us - (static_cast<uint64_t>(legacy_scan_result.age_ms) * 1000);
    if (aidl_scan_result->timeStampInUs < 0) {
    // Ensure that subtracting does not result in a negative value
    uint64_t age_us = static_cast<uint64_t>(legacy_scan_result.age_ms) * 1000;
    if (ts_us < age_us) {
        aidl_scan_result->timeStampInUs = 0;
        return false;
    }
    aidl_scan_result->timeStampInUs = ts_us - age_us;
    size_t max_len_excluding_null = sizeof(legacy_scan_result.ssid) - 1;
    size_t ssid_len = strnlen((const char*)legacy_scan_result.ssid, max_len_excluding_null);
    aidl_scan_result->ssid =