From 4f65172f6c059423f06670606099450e1d4ea237 Mon Sep 17 00:00:00 2001 From: Frederick Mayle Date: Wed, 5 Oct 2022 13:54:51 -0700 Subject: libbinder: avoid uninteresting protocol version crash in fuzzer Bug: 237640108 Test: android.hardware.vibrator-service.example_fuzzer Change-Id: I6c4d2b19c541a85a3236f0133d3dd0c0575ab444 --- libs/binder/tests/parcel_fuzzer/random_parcel.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libs/binder/tests/parcel_fuzzer/random_parcel.cpp b/libs/binder/tests/parcel_fuzzer/random_parcel.cpp index 51cb768d3d..1bfeefc9b2 100644 --- a/libs/binder/tests/parcel_fuzzer/random_parcel.cpp +++ b/libs/binder/tests/parcel_fuzzer/random_parcel.cpp @@ -45,6 +45,11 @@ void fillRandomParcel(Parcel* p, FuzzedDataProvider&& provider, RandomParcelOpti if (provider.ConsumeBool()) { auto session = RpcSession::make(RpcTransportCtxFactoryRaw::make()); CHECK_EQ(OK, session->addNullDebuggingClient()); + // Set the protocol version so that we don't crash if the session + // actually gets used. This isn't cheating because the version should + // always be set if the session init succeeded and we aren't testing the + // session init here (it is bypassed by addNullDebuggingClient). + session->setProtocolVersion(RPC_WIRE_PROTOCOL_VERSION); p->markForRpc(session); if (options->writeHeader) { -- cgit v1.2.3-59-g8ed1b