unescape_url_component_fuzzer.cc 621 B

12345678910111213141516171819202122
  1. // Copyright 2015 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include <stddef.h>
  5. #include <stdint.h>
  6. #include <string>
  7. #include "base/strings/escape.h"
  8. static const int kMaxUnescapeRule = 31;
  9. // Entry point for LibFuzzer.
  10. extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
  11. base::StringPiece path(reinterpret_cast<const char*>(data), size);
  12. for (int i = 0; i <= kMaxUnescapeRule; i++) {
  13. base::UnescapeURLComponent(path, static_cast<base::UnescapeRule::Type>(i));
  14. }
  15. return 0;
  16. }