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

Commit bec55231 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "libbinder_random_parcel: fuzz mult binders" am: e8c6fa84 am: 73f6315b

parents 5e783a87 73f6315b
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -19,7 +19,17 @@
#include <binder/IBinder.h>
#include <fuzzer/FuzzedDataProvider.h>

#include <vector>

namespace android {

/**
 * See fuzzService, but fuzzes multiple services at the same time.
 *
 * Consumes providers.
 */
void fuzzService(const std::vector<sp<IBinder>>& binders, FuzzedDataProvider&& provider);

/**
 * Based on the random data in provider, construct an arbitrary number of
 * Parcel objects and send them to the service in serial.
@@ -34,4 +44,5 @@ namespace android {
 *   }
 */
void fuzzService(const sp<IBinder>& binder, FuzzedDataProvider&& provider);

} // namespace android
+11 −0
Original line number Diff line number Diff line
@@ -16,10 +16,21 @@

#pragma once

#include <android/binder_auto_utils.h>
#include <android/binder_parcel.h>
#include <fuzzer/FuzzedDataProvider.h>

#include <vector>

namespace android {

/**
 * See fuzzService, but fuzzes multiple services at the same time.
 *
 * Consumes providers.
 */
void fuzzService(const std::vector<ndk::SpAIBinder>& binders, FuzzedDataProvider&& provider);

/**
 * Based on the random data in provider, construct an arbitrary number of
 * Parcel objects and send them to the service in serial.
+4 −2
Original line number Diff line number Diff line
@@ -24,10 +24,12 @@
namespace android {

void fuzzService(const sp<IBinder>& binder, FuzzedDataProvider&& provider) {
    sp<IBinder> target;
    fuzzService(std::vector<sp<IBinder>>{binder}, std::move(provider));
}

void fuzzService(const std::vector<sp<IBinder>>& binders, FuzzedDataProvider&& provider) {
    RandomParcelOptions options{
            .extraBinders = {binder},
            .extraBinders = binders,
            .extraFds = {},
    };

+9 −0
Original line number Diff line number Diff line
@@ -24,6 +24,15 @@

namespace android {

void fuzzService(const std::vector<ndk::SpAIBinder>& binders, FuzzedDataProvider&& provider) {
    std::vector<sp<IBinder>> cppBinders;
    for (const auto& binder : binders) {
        cppBinders.push_back(binder.get()->getBinder());
    }

    fuzzService(cppBinders, std::move(provider));
}

void fuzzService(AIBinder* binder, FuzzedDataProvider&& provider) {
    fuzzService(binder->getBinder(), std::move(provider));
}