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

Commit 7c29248d authored by Steven Moreland's avatar Steven Moreland
Browse files

libbinder_parcel_random: internalize RPC parcels

Recently, I changed binder_rpc_fuzzer to optional construct an RPC
parcel. However, it doesn't make sense for individual users of
libbinder_parcel_random to concern themselves with things like this.

Bug: 182938024
Test: N/A
Change-Id: I0d1cc5bafd0031f8cddf57a82a13f39cd36369e1
parent 33fd596d
Loading
Loading
Loading
Loading
+1 −14
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@
#include <iostream>

#include <android-base/logging.h>
#include <binder/RpcSession.h>
#include <fuzzbinder/random_parcel.h>
#include <fuzzer/FuzzedDataProvider.h>

@@ -33,7 +32,6 @@
#include <sys/time.h>

using android::fillRandomParcel;
using android::RpcSession;
using android::sp;

void fillRandomParcel(::android::hardware::Parcel* p, FuzzedDataProvider&& provider) {
@@ -59,18 +57,7 @@ void doFuzz(const char* backend, const std::vector<ParcelRead<P>>& reads,
            provider.ConsumeIntegralInRange<size_t>(0, maxInstructions));

    P p;
    if constexpr (std::is_same_v<P, android::Parcel>) {
        if (provider.ConsumeBool()) {
            auto session = sp<RpcSession>::make();
            CHECK(session->addNullDebuggingClient());
            p.markForRpc(session);
            fillRandomParcelData(&p, std::move(provider));
        } else {
    fillRandomParcel(&p, std::move(provider));
        }
    } else {
        fillRandomParcel(&p, std::move(provider));
    }

    // since we are only using a byte to index
    CHECK(reads.size() <= 255) << reads.size();
+9 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@

#include <android-base/logging.h>
#include <binder/IServiceManager.h>
#include <binder/RpcSession.h>
#include <fuzzbinder/random_fd.h>
#include <utils/String16.h>

@@ -33,6 +34,14 @@ private:
};

void fillRandomParcel(Parcel* p, FuzzedDataProvider&& provider) {
    if (provider.ConsumeBool()) {
        auto session = sp<RpcSession>::make();
        CHECK(session->addNullDebuggingClient());
        p->markForRpc(session);
        fillRandomParcelData(p, std::move(provider));
        return;
    }

    while (provider.remaining_bytes() > 0) {
        auto fillFunc = provider.PickValueInArray<const std::function<void()>>({
                // write data