Commit 4feb92de authored by Abhishek Arya's avatar Abhishek Arya Committed by Commit Bot

Add snappy compress fuzzer.

Also, rename snappy_fuzzer to snappy_uncompress_fuzzer.

R=mmoroz@chromium.org,pwnall@chromium.org

Bug: 900481
Change-Id: I83fa8be129f34dc2cbed4a21492139cea32c2044
Reviewed-on: https://chromium-review.googlesource.com/c/1337811
Commit-Queue: Abhishek Arya <inferno@chromium.org>
Reviewed-by: default avatarMax Moroz <mmoroz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608584}
parent a1c302cf
...@@ -40,13 +40,25 @@ fuzzer_test("language_detection_fuzzer") { ...@@ -40,13 +40,25 @@ fuzzer_test("language_detection_fuzzer") {
] ]
} }
fuzzer_test("snappy_fuzzer") { fuzzer_test("snappy_compress_fuzzer") {
sources = [ sources = [
"snappy_fuzzer.cc", "snappy_compress_fuzzer.cc",
]
deps = [
"//base",
"//third_party/snappy:snappy",
]
seed_corpus = "//third_party/snappy/src/testdata"
}
fuzzer_test("snappy_uncompress_fuzzer") {
sources = [
"snappy_uncompress_fuzzer.cc",
] ]
deps = [ deps = [
"//third_party/snappy:snappy", "//third_party/snappy:snappy",
] ]
seed_corpus = "//third_party/snappy/src/testdata"
} }
fuzzer_test("template_url_parser_fuzzer") { fuzzer_test("template_url_parser_fuzzer") {
......
// Copyright 2018 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 "base/logging.h"
#include "third_party/snappy/src/snappy.h"
// Entry point for LibFuzzer.
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
const char* uncompressed = reinterpret_cast<const char*>(data);
std::string compressed;
snappy::Compress(uncompressed, size, &compressed);
CHECK(snappy::IsValidCompressedBuffer(compressed.data(), compressed.size()));
std::string uncompressed_after_compress;
CHECK(snappy::Uncompress(compressed.data(), compressed.size(),
&uncompressed_after_compress));
CHECK_EQ(uncompressed_after_compress, std::string(uncompressed, size));
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