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

Commit 01c9cdc1 authored by Devin Moore's avatar Devin Moore
Browse files

binder_parcel_fuzzer: close FDs in unflatten

Even if we don't want to use them, we need to take ownership and close
them to avoid leaking.

Ignore-AOSP-First: na
Flag: TEST_ONLY
Test: binder_parcel_fuzzer
Bug: 406499223
Change-Id: I01f5f1d5da49067116eaee72af64ac08a3f05413
parent 7690add0
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -62,13 +62,17 @@ public:
        FUZZ_LOG() << "should not reach";
        abort();
    }
    status_t unflatten(void const*& buffer, size_t& size, int const*& /*fds*/, size_t& /*count*/) {
    status_t unflatten(void const*& buffer, size_t& size, int const*& fds, size_t& count) {
        for (size_t i = 0; i < count; i++) {
            close(fds[i]);
        }
        if (size < sizeof(mValue)) {
            return android::NO_MEMORY;
        }
        android::FlattenableUtils::read(buffer, size, mValue);
        return android::OK;
    }

private:
    int32_t mValue = 0xFEEDBEEF;
};