Skip to content

Commit 01c9cdc

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
1 parent 7690add commit 01c9cdc

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

libs/binder/tests/parcel_fuzzer/binder.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,17 @@ struct ExampleFlattenable : public android::Flattenable<ExampleFlattenable> {
6262
FUZZ_LOG() << "should not reach";
6363
abort();
6464
}
65-
status_t unflatten(void const*& buffer, size_t& size, int const*& /*fds*/, size_t& /*count*/) {
65+
status_t unflatten(void const*& buffer, size_t& size, int const*& fds, size_t& count) {
66+
for (size_t i = 0; i < count; i++) {
67+
close(fds[i]);
68+
}
6669
if (size < sizeof(mValue)) {
6770
return android::NO_MEMORY;
6871
}
6972
android::FlattenableUtils::read(buffer, size, mValue);
7073
return android::OK;
7174
}
75+
7276
private:
7377
int32_t mValue = 0xFEEDBEEF;
7478
};

0 commit comments

Comments
 (0)