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

Commit 08f15205 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "binder_parcel_fuzzer: split out random_parcel.h"

parents a4d3a69c 362e4da2
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ cc_fuzz {
    ],
    static_libs: [
        "libbase",
        "libbinder_random_parcel",
        "libcgrouprc",
        "libcgrouprc_format",
        "libcutils",
@@ -47,3 +48,20 @@ cc_fuzz {
    // produced, you may find uncommenting the below line very useful.
    // cflags: ["-DENABLE_LOG_FUZZ"],
}

cc_library_static {
    name: "libbinder_random_parcel",
    host_supported: true,
    srcs: [
        "random_fd.cpp",
        "random_parcel.cpp",
    ],
    shared_libs: [
        "libbase",
        "libbinder",
        "libcutils",
        "libutils",
    ],
    local_include_dirs: ["include_random_parcel"],
    export_include_dirs: ["include_random_parcel"],
}
+0 −3
Original line number Diff line number Diff line
@@ -16,12 +16,9 @@

#pragma once

#include "binder_ndk.h"

#include <binder/Parcel.h>
#include <fuzzer/FuzzedDataProvider.h>

namespace android {
void fillRandomParcel(Parcel* p, FuzzedDataProvider&& provider);
void fillRandomParcel(NdkParcelAdapter* p, FuzzedDataProvider&& provider);
} // namespace android
+6 −1
Original line number Diff line number Diff line
@@ -18,10 +18,10 @@
#include "binder.h"
#include "binder_ndk.h"
#include "hwbinder.h"
#include "random_parcel.h"
#include "util.h"

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

#include <cstdlib>
@@ -30,9 +30,14 @@
using android::fillRandomParcel;

void fillRandomParcel(::android::hardware::Parcel* p, FuzzedDataProvider&& provider) {
    // TODO: functionality to create random parcels for libhwbinder parcels
    std::vector<uint8_t> input = provider.ConsumeRemainingBytes<uint8_t>();
    p->setData(input.data(), input.size());
}
static void fillRandomParcel(NdkParcelAdapter* p, FuzzedDataProvider&& provider) {
    // fill underlying parcel using functions to fill random libbinder parcel
    fillRandomParcel(p->parcel(), std::move(provider));
}

template <typename P>
void doFuzz(const char* backend, const std::vector<ParcelRead<P>>& reads,
+1 −1
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@
 * limitations under the License.
 */

#include "random_fd.h"
#include <fuzzbinder/random_fd.h>

#include <fcntl.h>

Loading