blob: 622cafc7df7d156c2d05567343bedd8b784f1747 [file] [log] [blame]
Steven Moreland28f81422019-10-03 10:40:59 -07001/*
2 * Copyright (C) 2019 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <android/binder_auto_utils.h>
18#include <vector>
19
20#include <android/binder_parcel.h>
21#include "parcel_fuzzer.h"
22
23// libbinder_ndk doesn't export this header which breaks down its API for NDK
24// and APEX users, but we need access to it to fuzz.
25#include "../ndk/parcel_internal.h"
26
27class NdkParcelAdapter {
28public:
29 NdkParcelAdapter() : mParcel(new AParcel(nullptr /*binder*/)) {}
30
31 const AParcel* aParcel() const { return mParcel.get(); }
32 AParcel* aParcel() { return mParcel.get(); }
33
34 size_t dataSize() const { return aParcel()->get()->dataSize(); }
35 size_t dataAvail() const { return aParcel()->get()->dataAvail(); }
36 size_t dataPosition() const { return aParcel()->get()->dataPosition(); }
37 size_t dataCapacity() const { return aParcel()->get()->dataCapacity(); }
38 android::status_t setData(const uint8_t* buffer, size_t len) {
39 return aParcel()->get()->setData(buffer, len);
40 }
41
42private:
43 ndk::ScopedAParcel mParcel;
44};
45
46extern std::vector<ParcelRead<NdkParcelAdapter>> BINDER_NDK_PARCEL_READ_FUNCTIONS;