diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2020-12-16 02:11:16 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2020-12-16 02:11:16 +0000 |
commit | 4be1d3ea40646cb64b0681817dac97ca85c3312e (patch) | |
tree | 90a80f4ffcedbb9649123a373c334be4a196bd06 | |
parent | beaf5f936115bf009f92f3614fccbc646691875f (diff) | |
parent | c44552e662b9f9ab541b2c9bd6f64d39c039d610 (diff) | |
download | libwebm-4be1d3ea40646cb64b0681817dac97ca85c3312e.tar.gz |
Snap for 7035284 from c44552e662b9f9ab541b2c9bd6f64d39c039d610 to sc-d1-release
Change-Id: I35a82ff32b4e0a096c6f1e295e0461830e512047
-rw-r--r-- | fuzzing/Android.bp | 43 | ||||
-rw-r--r-- | fuzzing/common.cpp | 58 | ||||
-rw-r--r-- | fuzzing/common.h | 39 | ||||
-rw-r--r-- | fuzzing/mkvmuxer_one_video_audio_track.cpp | 71 | ||||
-rw-r--r-- | fuzzing/mkvmuxer_one_video_track.cpp | 54 |
5 files changed, 0 insertions, 265 deletions
diff --git a/fuzzing/Android.bp b/fuzzing/Android.bp deleted file mode 100644 index 50da3e3..0000000 --- a/fuzzing/Android.bp +++ /dev/null @@ -1,43 +0,0 @@ -// -// 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. - -cc_library { - name: "libwebm_mkvmuxer_fuzzer_common", - srcs: ["common.cpp"], - shared_libs: ["libwebm_mkvmuxer"], - host_supported: true, -} - -cc_defaults { - name: "libwebm_mkvmuxer_fuzzer_defaults", - shared_libs: [ - "libwebm_mkvmuxer_fuzzer_common", - "libwebm_mkvmuxer", - ], - host_supported: true, - fuzz_config: { componentid: 46263 }, -} - -cc_fuzz { - name: "libwebm_mkvmuxer_fuzzer_one_video_track", - srcs: ["mkvmuxer_one_video_track.cpp"], - defaults: ["libwebm_mkvmuxer_fuzzer_defaults"], -} - -cc_fuzz { - name: "libwebm_mkvmuxer_fuzzer_one_video_audio_track", - srcs: ["mkvmuxer_one_video_audio_track.cpp"], - defaults: ["libwebm_mkvmuxer_fuzzer_defaults"], -} diff --git a/fuzzing/common.cpp b/fuzzing/common.cpp deleted file mode 100644 index 5709673..0000000 --- a/fuzzing/common.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// -// 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. - -#include "fuzzing/common.h" - -using mkvmuxer::int32; -using mkvmuxer::int64; -using mkvmuxer::uint32; -using mkvmuxer::uint64; - -DiscardingMkvWriter::DiscardingMkvWriter() : position_(0), checksum_(0) {} - -int32 DiscardingMkvWriter::Write(const void* buf, uint32 len) { - auto data = static_cast<const uint8_t*>(buf); - for (uint32 i = 0; i < len; i++) { - // Force reads on all data in buf so ASAN can validate it - checksum_ += data[i]; - } - position_ += len; - return 0; -} - -int64 DiscardingMkvWriter::Position() const { - return position_; -} - -int32 DiscardingMkvWriter::Position(int64 position) { - position_ = position; - return 0; -} - -bool DiscardingMkvWriter::Seekable() const { - return true; -} - -void DiscardingMkvWriter::ElementStartNotify(uint64, int64) { -} - -std::vector<uint8_t> FuzzerRandomLengthBytes(FuzzedDataProvider& fdp) { - // https://github.com/google/fuzzing/blob/master/docs/split-inputs.md#main-concepts - // ConsumeRandomLengthString is a good source of data, but we have to remove - // the null terminator to not hide off-by-one access errors. - std::string str = fdp.ConsumeRandomLengthString(); - std::vector<uint8_t> data(str.begin(), str.end()); - return data; -} diff --git a/fuzzing/common.h b/fuzzing/common.h deleted file mode 100644 index b0f498e..0000000 --- a/fuzzing/common.h +++ /dev/null @@ -1,39 +0,0 @@ -// -// 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. - -#pragma once - -#include <stdint.h> -#include <vector> - -#include "mkvmuxer/mkvmuxer.h" -#include "fuzzer/FuzzedDataProvider.h" - -class DiscardingMkvWriter : public mkvmuxer::IMkvWriter { -public: - DiscardingMkvWriter(); - - mkvmuxer::int32 Write(const void* buf, mkvmuxer::uint32 len) override; - mkvmuxer::int64 Position() const override; - mkvmuxer::int32 Position(mkvmuxer::int64 position) override; - bool Seekable() const override; - void ElementStartNotify(mkvmuxer::uint64, mkvmuxer::int64) override; - -private: - mkvmuxer::int64 position_; - mkvmuxer::int64 checksum_; -}; - -std::vector<uint8_t> FuzzerRandomLengthBytes(FuzzedDataProvider&); diff --git a/fuzzing/mkvmuxer_one_video_audio_track.cpp b/fuzzing/mkvmuxer_one_video_audio_track.cpp deleted file mode 100644 index b51788a..0000000 --- a/fuzzing/mkvmuxer_one_video_audio_track.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// -// 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. - -#include <stddef.h> -#include <stdint.h> - -#include <sstream> - -#include "fuzzer/FuzzedDataProvider.h" -#include "mkvmuxer/mkvmuxer.h" -#include "fuzzing/common.h" - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { - FuzzedDataProvider fdp(data, size); - - mkvmuxer::Segment segment; - DiscardingMkvWriter writer; - segment.Init(&writer); - - auto width = fdp.ConsumeIntegral<int32_t>(); - auto height = fdp.ConsumeIntegral<int32_t>(); - - uint64_t video_track_number = segment.AddVideoTrack(width, height, 0); - - if (video_track_number == 0) { - return 0; - } - - auto sample_rate = fdp.ConsumeIntegral<int32_t>(); - auto channels = fdp.ConsumeIntegral<int32_t>(); - - uint64_t audio_track_number = segment.AddAudioTrack(sample_rate, channels, 0); - - if (audio_track_number == 0) { - return 0; - } - - while (fdp.remaining_bytes() > 0) { - auto video_frame = FuzzerRandomLengthBytes(fdp); - segment.AddFrame( - video_frame.data(), - video_frame.size(), - video_track_number, - fdp.ConsumeIntegral<uint64_t>(), - fdp.ConsumeBool()); - - auto audio_frame = FuzzerRandomLengthBytes(fdp); - segment.AddFrame( - audio_frame.data(), - audio_frame.size(), - audio_track_number, - fdp.ConsumeIntegral<uint64_t>(), - fdp.ConsumeBool()); - } - - segment.Finalize(); - - return 0; -} diff --git a/fuzzing/mkvmuxer_one_video_track.cpp b/fuzzing/mkvmuxer_one_video_track.cpp deleted file mode 100644 index b4f1bdc..0000000 --- a/fuzzing/mkvmuxer_one_video_track.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// -// 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. - -#include <stddef.h> -#include <stdint.h> - -#include <sstream> - -#include "fuzzer/FuzzedDataProvider.h" -#include "mkvmuxer/mkvmuxer.h" -#include "fuzzing/common.h" - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { - FuzzedDataProvider fdp(data, size); - - mkvmuxer::Segment segment; - DiscardingMkvWriter writer; - segment.Init(&writer); - - int width = fdp.ConsumeIntegral<int>(); - int height = fdp.ConsumeIntegral<int>(); - - uint64_t video_track_number = segment.AddVideoTrack(width, height, 0); - - if (video_track_number == 0) { - return 0; - } - - while (fdp.remaining_bytes() > 0) { - auto frame = FuzzerRandomLengthBytes(fdp); - segment.AddFrame( - frame.data(), - frame.size(), - video_track_number, - fdp.ConsumeIntegral<uint64_t>(), - fdp.ConsumeBool()); - } - - segment.Finalize(); - - return 0; -} |