summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJán Sebechlebský <jsebechlebsky@google.com>2023-11-08 11:17:40 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2023-11-08 11:17:40 +0000
commit54df502755b39bb9599cb7dff10fcc2ea8e0be33 (patch)
tree474f636ad8a2799440c864378afd7881cba0f8b1
parent439a4b8aff8072e58f7cefd382a7171b834d78f5 (diff)
parentb9fac05988e7a8c57adaddfc777bfe88e47536ac (diff)
downloadcamera-54df502755b39bb9599cb7dff10fcc2ea8e0be33.tar.gz
Merge changes I608d5309,I6b26fd8b into main
* changes: Add fuzzer for Virtual Camera service. Remove redundant libandroid dependency.
-rw-r--r--devices/VirtualCamera/Android.bp1
-rw-r--r--devices/VirtualCamera/fuzzer/Android.bp46
-rw-r--r--devices/VirtualCamera/fuzzer/virtual_camera_fuzzer.cc42
3 files changed, 88 insertions, 1 deletions
diff --git a/devices/VirtualCamera/Android.bp b/devices/VirtualCamera/Android.bp
index b4e9133..970c535 100644
--- a/devices/VirtualCamera/Android.bp
+++ b/devices/VirtualCamera/Android.bp
@@ -13,7 +13,6 @@ cc_defaults {
"libcamera_metadata",
"liblog",
"libfmq",
- "libandroid",
"libgui",
"libjpeg",
"libnativewindow",
diff --git a/devices/VirtualCamera/fuzzer/Android.bp b/devices/VirtualCamera/fuzzer/Android.bp
new file mode 100644
index 0000000..71e8f50
--- /dev/null
+++ b/devices/VirtualCamera/fuzzer/Android.bp
@@ -0,0 +1,46 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *****************************************************************************/
+ package {
+ // See: http://go/android-license-faq
+ default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+cc_fuzz {
+ name: "virtual_camera_fuzzer",
+ defaults: [
+ "libvirtualcamera_defaults",
+ "service_fuzzer_defaults",
+ ],
+ static_libs: [
+ "libvirtualcamera",
+ "libvirtualcamera_utils",
+ ],
+ srcs: [
+ "virtual_camera_fuzzer.cc",
+ ],
+ fuzz_config: {
+ cc: [
+ "if-xr+fuzzer@google.com",
+ ],
+ componentid: 1171888,
+ hotlists: [
+ "5426614",
+ ],
+ description: "The fuzzers target the APIs of virtual_camera binary",
+ },
+}
diff --git a/devices/VirtualCamera/fuzzer/virtual_camera_fuzzer.cc b/devices/VirtualCamera/fuzzer/virtual_camera_fuzzer.cc
new file mode 100644
index 0000000..ebd5e73
--- /dev/null
+++ b/devices/VirtualCamera/fuzzer/virtual_camera_fuzzer.cc
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <android-base/logging.h>
+#include <android/binder_interface_utils.h>
+#include <fuzzbinder/libbinder_ndk_driver.h>
+#include <fuzzer/FuzzedDataProvider.h>
+
+#include "VirtualCameraProvider.h"
+#include "VirtualCameraService.h"
+
+using android::fuzzService;
+using ::android::companion::virtualcamera::VirtualCameraProvider;
+using ::android::companion::virtualcamera::VirtualCameraService;
+using ndk::SharedRefBase;
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
+ std::shared_ptr<VirtualCameraProvider> defaultProvider =
+ SharedRefBase::make<VirtualCameraProvider>();
+
+ fuzzService(defaultProvider->asBinder().get(), FuzzedDataProvider(data, size));
+
+ const std::string serviceName =
+ std::string(VirtualCameraProvider::descriptor) + "/virtual/0";
+ auto binder = SharedRefBase::make<VirtualCameraService>(defaultProvider);
+
+ fuzzService(binder->asBinder().get(), FuzzedDataProvider(data, size));
+ return 0;
+}