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

Commit b2a640f5 authored by Devin Moore's avatar Devin Moore Committed by Android (Google) Code Review
Browse files

Merge "random_parcel: don't always make a parcel view when filling a random parcel" into main

parents 5e116051 87816ee5
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -29,7 +29,12 @@ struct RandomParcelOptions {
    std::vector<sp<IBinder>> extraBinders;
    std::vector<binder::unique_fd> extraFds;

    // internal state owned by fillRandomParcel, for Parcel views
    // Only use extraParcels when this is true. This object needs to outlive
    // the views
    bool viewParcel = false;
    // internal state owned by fillRandomParcel, for Parcel views.
    // This can only be used if this RandomParcelOptions objects is guaranteed
    // to outlive the views.
    std::vector<std::unique_ptr<Parcel>> extraParcels;
};

+1 −0
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ void fuzzService(const std::vector<sp<IBinder>>& binders, FuzzedDataProvider&& p
    RandomParcelOptions options{
            .extraBinders = binders,
            .extraFds = {},
            .viewParcel = true,
    };

    // Reserved bytes so that we don't have to change fuzzers and seed corpus if
+2 −2
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ void fillRandomParcel(Parcel* outputParcel, FuzzedDataProvider&& provider,
    });

    Parcel* p;
    if (resultShouldBeView) {
    if (options->viewParcel && resultShouldBeView) {
        options->extraParcels.push_back(std::make_unique<Parcel>());
        // held for duration of test, so that view will be valid
        p = options->extraParcels[options->extraParcels.size() - 1].get();
@@ -60,7 +60,7 @@ void fillRandomParcel(Parcel* outputParcel, FuzzedDataProvider&& provider,
    // must be last guard, so outputParcel gets setup as view before
    // other guards
    auto viewify_guard = binder::impl::make_scope_guard([&]() {
        if (resultShouldBeView) {
        if (options->viewParcel && resultShouldBeView) {
            outputParcel->makeDangerousViewOf(p);
        }
    });