• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2020 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 #pragma once
18 
19 #include <binder/Binder.h>
20 #include <binder/Stability.h>
21 #include <fuzzer/FuzzedDataProvider.h>
22 
23 #define STABILITY_MAX_TAG_LENGTH 2048
24 static bool marked = false;
25 
26 /* This is a vector of lambda functions the fuzzer will pull from.
27  *  This is done so new functions can be added to the fuzzer easily
28  *  without requiring modifications to the main fuzzer file. This also
29  *  allows multiple fuzzers to include this file, if functionality is needed.
30  */
31 static const std::vector<
32         std::function<void(FuzzedDataProvider*, android::sp<android::IBinder> const&)>>
33         gStabilityOperations = {
34                 [](FuzzedDataProvider*, android::sp<android::IBinder> const& bbinder) -> void {
35                     if (!marked) {
36                         android::internal::Stability::markCompilationUnit(bbinder.get());
37                         marked = true;
38                     }
39                 },
40                 [](FuzzedDataProvider*, android::sp<android::IBinder> const& bbinder) -> void {
41                     if (!marked) {
42                         android::internal::Stability::markVintf(bbinder.get());
43                         marked = true;
44                     }
45                 },
46                 [](FuzzedDataProvider*, android::sp<android::IBinder> const& bbinder) -> void {
47                     (void)android::internal::Stability::debugToString(bbinder);
48                 },
49                 [](FuzzedDataProvider*, android::sp<android::IBinder> const& bbinder) -> void {
50                     if (!marked) {
51                         android::internal::Stability::markVndk(bbinder.get());
52                         marked = true;
53                     }
54                 },
55                 [](FuzzedDataProvider*, android::sp<android::IBinder> const& bbinder) -> void {
56                     android::internal::Stability::requiresVintfDeclaration(bbinder);
57                 }};
58