Commit eca3d763 authored by Daniel McArdle's avatar Daniel McArdle Committed by Commit Bot

Add media/audio/wav_audio_handler_fuzzer

This adds fuzzer coverage for wav_audio_handler.cc.

Fuzzer coverage report: https://chromium-coverage.appspot.com/reports/737219_fuzzers_only/linux/chromium/src/media/audio/wav_audio_handler.cc.html

Change-Id: I60176aba90301bcab648029511a27c16c93ef736
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2033443Reviewed-by: default avatarOlga Sharonova <olka@chromium.org>
Commit-Queue: Dan McArdle <dmcardle@chromium.org>
Cr-Commit-Position: refs/heads/master@{#737778}
parent 3c3b514d
......@@ -4,6 +4,7 @@
import("//build/config/linux/pkg_config.gni")
import("//media/media_options.gni")
import("//testing/libfuzzer/fuzzer_test.gni")
import("//tools/generate_stubs/rules.gni")
# When libpulse is not directly linked, use stubs to allow for dlopening of the
......@@ -38,6 +39,7 @@ source_set("audio") {
# is a roll-up target which is part of the //media component. Most other DEPs
# should be using //media and not directly DEP this roll-up target.
visibility = [
":wav_audio_handler_fuzzer",
"//media",
"//media/renderers",
......@@ -451,3 +453,12 @@ source_set("unit_tests") {
]
}
}
fuzzer_test("wav_audio_handler_fuzzer") {
sources = [ "wav_audio_handler_fuzzer.cc" ]
deps = [
":audio",
"//base",
"//media:test_support",
]
}
// Copyright 2020 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 <stddef.h>
#include <stdint.h>
#include <memory>
#include "base/logging.h"
#include "media/audio/wav_audio_handler.h"
#include "media/base/audio_bus.h"
struct Environment {
Environment() { logging::SetMinLogLevel(logging::LOG_FATAL); }
};
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
static Environment env;
base::StringPiece wav_data(reinterpret_cast<const char*>(data), size);
std::unique_ptr<media::WavAudioHandler> handler =
media::WavAudioHandler::Create(wav_data);
if (!handler) {
return 0;
}
std::unique_ptr<media::AudioBus> audio_bus =
media::AudioBus::Create(handler->num_channels(), handler->total_frames());
size_t bytes_written;
handler->CopyTo(audio_bus.get(), 0, &bytes_written);
return 0;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment