summaryrefslogtreecommitdiff
path: root/keystore2/src/fuzzers
diff options
context:
space:
mode:
authorhamzeh <hamzeh@google.com>2021-06-09 11:04:14 -0700
committerHamzeh Zawawy <hamzeh@google.com>2021-07-07 21:32:41 +0000
commit266abdb62798124810e227c2ffe06c914eafa9d6 (patch)
treee113ba949d084cb5a876a5bd44bd38e3b44cf351 /keystore2/src/fuzzers
parent1bca8c905e2013b07b185cdf71ea0ac79a0c55ea (diff)
downloadsecurity-266abdb62798124810e227c2ffe06c914eafa9d6.tar.gz
Adding skeleton for a rust fuzzer for legacy_blob
Test: m legacy_blob_fuzzer & adb sync data & adb shell legacy_blob_fuzzer The edge coverage after running for few minutes was about 15 percent. Change-Id: I8a8a535319c6146c67980e6c31e5c85c420e40e7
Diffstat (limited to 'keystore2/src/fuzzers')
-rw-r--r--keystore2/src/fuzzers/Android.bp29
-rw-r--r--keystore2/src/fuzzers/legacy_blob_fuzzer.rs24
2 files changed, 53 insertions, 0 deletions
diff --git a/keystore2/src/fuzzers/Android.bp b/keystore2/src/fuzzers/Android.bp
new file mode 100644
index 00000000..384ab77f
--- /dev/null
+++ b/keystore2/src/fuzzers/Android.bp
@@ -0,0 +1,29 @@
+// Copyright 2021, 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 {
+ default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+rust_fuzz {
+ name: "legacy_blob_fuzzer",
+ srcs: ["legacy_blob_fuzzer.rs"],
+ rustlibs: [
+ "libkeystore2",
+ ],
+ fuzz_config: {
+ fuzz_on_haiku_device: true,
+ fuzz_on_haiku_host: false,
+ },
+}
diff --git a/keystore2/src/fuzzers/legacy_blob_fuzzer.rs b/keystore2/src/fuzzers/legacy_blob_fuzzer.rs
new file mode 100644
index 00000000..5c89ca4f
--- /dev/null
+++ b/keystore2/src/fuzzers/legacy_blob_fuzzer.rs
@@ -0,0 +1,24 @@
+// Copyright 2021, 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.
+
+#![allow(missing_docs)]
+#![no_main]
+#[macro_use]
+extern crate libfuzzer_sys;
+use keystore2::legacy_blob::LegacyBlobLoader;
+
+fuzz_target!(|data: &[u8]| {
+ let string = data.iter().filter_map(|c| std::char::from_u32(*c as u32)).collect::<String>();
+ let _res = LegacyBlobLoader::decode_alias(&string);
+});