diff options
author | Ayushi Khopkar <ayushi.khopkar@ittiam.com> | 2022-04-28 08:39:04 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2022-04-28 08:39:04 +0000 |
commit | d28c1eabfc4fbb977c319581f095a55e77eb50cc (patch) | |
tree | b92300130ed4fa30ebf35c923b87f219cf2b9c2b | |
parent | 0767f0c7cc17fb264201eea18f801dc0571b5c90 (diff) | |
parent | 1fe1528c295381cb1ec715a331f1b47e362a62f1 (diff) | |
download | libldac-d28c1eabfc4fbb977c319581f095a55e77eb50cc.tar.gz |
Added libldac-encode_fuzzer am: ba39d802d7 am: 8113ef979a am: 198b34618d am: 1fe1528c29
Original change: https://android-review.googlesource.com/c/platform/external/libldac/+/2015995
Change-Id: I2d4a8689ef304f6dd4669fc7c6e8fd9e4b7f9edf
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | fuzzer/Android.bp | 26 | ||||
-rw-r--r-- | fuzzer/libldac_encode_fuzzer.cc | 47 | ||||
-rw-r--r-- | fuzzer/ossfuzz.sh | 27 |
3 files changed, 100 insertions, 0 deletions
diff --git a/fuzzer/Android.bp b/fuzzer/Android.bp new file mode 100644 index 0000000..1d2620f --- /dev/null +++ b/fuzzer/Android.bp @@ -0,0 +1,26 @@ +// Copyright (C) 2020 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: ["external_libldac_license"], +} + +cc_fuzz { + name: "libldac-encode_fuzzer", + shared_libs: ["libldacBT_enc"], + srcs: ["libldac_encode_fuzzer.cc"], + fuzz_config: { + componentid: 27441 + }, +} diff --git a/fuzzer/libldac_encode_fuzzer.cc b/fuzzer/libldac_encode_fuzzer.cc new file mode 100644 index 0000000..2f293f1 --- /dev/null +++ b/fuzzer/libldac_encode_fuzzer.cc @@ -0,0 +1,47 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include <stdint.h> +#include <stddef.h> +#include "ldacBT.h" + +#define TESTFUNC_TYPE extern "C" int + +TESTFUNC_TYPE +LLVMFuzzerTestOneInput(const uint8_t *buf, size_t size) +{ + if (size == 0) { + return 0; + } + HANDLE_LDAC_BT hLdacBt; + int pcm_used, stream_sz, frame_num; + unsigned char p_stream[1024]; + + hLdacBt = ldacBT_get_handle(); + + ldacBT_init_handle_encode( + hLdacBt, + 679, + LDACBT_EQMID_SQ, + LDACBT_CHANNEL_MODE_DUAL_CHANNEL, + LDACBT_SMPL_FMT_S16, + 48000); + + ldacBT_encode( + hLdacBt, + (void *)(&buf + 44), + &pcm_used, + p_stream, + &stream_sz, + &frame_num); + + ldacBT_get_sampling_freq(hLdacBt); + ldacBT_get_bitrate(hLdacBt); + ldacBT_get_version(); + + ldacBT_close_handle(hLdacBt); + ldacBT_free_handle(hLdacBt); + + return 0; +} diff --git a/fuzzer/ossfuzz.sh b/fuzzer/ossfuzz.sh new file mode 100644 index 0000000..75b4658 --- /dev/null +++ b/fuzzer/ossfuzz.sh @@ -0,0 +1,27 @@ +# Copyright (C) 2022 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. +# +################################################################################ + +$CC $CFLAGS -Iinc -c fuzzer/libldac_encode_fuzzer.cc -o libldac_encode_fuzzer.o +$CC $CFLAGS -Iinc -c src/ldaclib.c -o src/ldaclib.o +$CC $CFLAGS -Iinc -c src/ldacBT.c -o src/ldacBT.o + +$CXX $CXXFLAGS $LIB_FUZZING_ENGINE \ + libldac_encode_fuzzer.o \ + src/ldaclib.o \ + src/ldacBT.o \ + -o $OUT/libldac_encode_fuzzer + +zip -q $OUT/libldac_encode_fuzzer_seed_corpus.zip $SRC/corpora/* |