Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Unified Diff: net/filter/brotli_source_stream_fuzzer.cc

Issue 2463233002: Add a BrotliSourceStream fuzzer (Closed)
Patch Set: Correct typo in gzip file Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/BUILD.gn ('k') | net/filter/gzip_source_stream_fuzzer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/filter/brotli_source_stream_fuzzer.cc
diff --git a/net/filter/gzip_source_stream_fuzzer.cc b/net/filter/brotli_source_stream_fuzzer.cc
similarity index 61%
copy from net/filter/gzip_source_stream_fuzzer.cc
copy to net/filter/brotli_source_stream_fuzzer.cc
index e380ca7f0179a59ca3e2d71c93234369aa7d45d9..868abc868389a55ddf23f13b92faa80cf2fa2521 100644
--- a/net/filter/gzip_source_stream_fuzzer.cc
+++ b/net/filter/brotli_source_stream_fuzzer.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "net/filter/gzip_source_stream.h"
+#include "net/filter/brotli_source_stream.h"
#include "base/logging.h"
#include "base/memory/ref_counted.h"
@@ -10,28 +10,23 @@
#include "net/base/io_buffer.h"
#include "net/base/test_completion_callback.h"
#include "net/filter/fuzzed_source_stream.h"
+#include "net/filter/source_stream.h"
-// Fuzzer for GzipSourceStream.
+// Fuzzer for BrotliSourceStream.
//
-// |data| is used to create a FuzzedSocket.
+// |data| is used to create a FuzzedSourceStream.
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
net::TestCompletionCallback callback;
base::FuzzedDataProvider data_provider(data, size);
std::unique_ptr<net::FuzzedSourceStream> fuzzed_source_stream(
new net::FuzzedSourceStream(&data_provider));
-
- const net::SourceStream::SourceType kGzipTypes[] = {
- net::SourceStream::TYPE_GZIP, net::SourceStream::TYPE_DEFLATE,
- net::SourceStream::TYPE_GZIP_FALLBACK};
- net::SourceStream::SourceType type =
- data_provider.PickValueInArray(kGzipTypes);
- std::unique_ptr<net::GzipSourceStream> gzip_stream =
- net::GzipSourceStream::Create(std::move(fuzzed_source_stream), type);
+ std::unique_ptr<net::SourceStream> brotli_stream =
+ net::CreateBrotliSourceStream(std::move(fuzzed_source_stream));
while (true) {
scoped_refptr<net::IOBufferWithSize> io_buffer(
new net::IOBufferWithSize(64));
- int result = gzip_stream->Read(io_buffer.get(), io_buffer->size(),
- callback.callback());
+ int result = brotli_stream->Read(io_buffer.get(), io_buffer->size(),
+ callback.callback());
// Releasing the pointer to IOBuffer immediately is more likely to lead to a
// use-after-free.
io_buffer = nullptr;
« no previous file with comments | « net/BUILD.gn ('k') | net/filter/gzip_source_stream_fuzzer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698