| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 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 | |
| 5 #include <stdint.h> | |
| 6 | |
| 7 #include "crypto/openssl_bio_string.h" | |
| 8 #include "crypto/scoped_openssl_types.h" | |
| 9 | |
| 10 | |
| 11 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { | |
| 12 if (size == 0) { return 0; } | |
| 13 | |
| 14 std::string buffer; | |
| 15 std::string input(reinterpret_cast<const char*>(data), size); | |
| 16 | |
| 17 std::size_t data_hash = std::hash<std::string>()(input); | |
| 18 uint8_t choice = data_hash % 3; | |
| 19 | |
| 20 crypto::ScopedBIO bio(crypto::BIO_new_string(&buffer)); | |
| 21 if (choice == 0) { | |
| 22 BIO_printf(bio.get(), "%s", input.c_str()); | |
| 23 } else if (choice == 1) { | |
| 24 BIO_write(bio.get(), input.c_str(), size); | |
| 25 } else { | |
| 26 BIO_puts(bio.get(), input.c_str()); | |
| 27 } | |
| 28 BIO_flush(bio.get()); | |
| 29 | |
| 30 return 0; | |
| 31 } | |
| 32 | |
| OLD | NEW |