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

Commit cd21a20b authored by Devin Moore's avatar Devin Moore
Browse files

random_binder: don't try to get ServiceManager on host

There is no ServiceManager binder on host, so don't try to get it.

Alternative considered:
setDefaultServiceManager(sp<FakeServiceManager>::make());
But if that's called after the process already called
setDefaultServiceManager or defaultServiceManager, it will abort. So
existing users of libbinder_random_parcel would break.

Flag: EXEMPT test only
Test: binder_parcel_fuzzer # host and device
Bug: 407122315
Change-Id: I2a36ac54bac5f088d9a3e8a2f359b7a5acaddc16
parent 6e578e5b
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -76,13 +76,16 @@ sp<IBinder> getRandomBinder(FuzzedDataProvider* provider) {

                return new RandomBinder(String16(str.c_str()), std::move(bytes));
            },
#ifdef __ANDROID__
            []() {
                // this is the easiest remote binder to get ahold of, and it
                // should be able to handle anything thrown at it, and
                // essentially every process can talk to it, so it's a good
                // candidate for checking usage of an actual BpBinder
                // This only works on an Android device with binder enabled
                return IInterface::asBinder(defaultServiceManager());
            },
#endif
            [&]() -> sp<IBinder> { return nullptr; },
    });
    return makeFunc();