OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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 <stddef.h> |
| 6 #include <stdint.h> |
| 7 |
| 8 #include "base/test/fuzzed_data_provider.h" |
| 9 #include "net/ntlm/ntlm_client.h" |
| 10 #include "net/ntlm/ntlm_test_data.h" |
| 11 |
| 12 base::string16 ConsumeRandomLengthString16( |
| 13 base::FuzzedDataProvider& data_provider, |
| 14 size_t max_chars) { |
| 15 std::string bytes = data_provider.ConsumeRandomLengthString(max_chars * 2); |
| 16 return base::string16(reinterpret_cast<const base::char16*>(bytes.data()), |
| 17 bytes.size() / 2); |
| 18 } |
| 19 |
| 20 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { |
| 21 net::ntlm::NtlmClient client; |
| 22 |
| 23 // Generate the input strings and challenge message. The strings will have a |
| 24 // maximum length 1 character longer than the maximum that |NtlmClient| will |
| 25 // accept to allow exploring the error cases. |
| 26 base::FuzzedDataProvider fdp(data, size); |
| 27 base::string16 domain = |
| 28 ConsumeRandomLengthString16(fdp, net::ntlm::kMaxFqdnLen + 1); |
| 29 base::string16 username = |
| 30 ConsumeRandomLengthString16(fdp, net::ntlm::kMaxUsernameLen + 1); |
| 31 base::string16 password = |
| 32 ConsumeRandomLengthString16(fdp, net::ntlm::kMaxPasswordLen + 1); |
| 33 std::string hostname = |
| 34 fdp.ConsumeRandomLengthString(net::ntlm::kMaxFqdnLen + 1); |
| 35 std::string challenge_msg_bytes = fdp.ConsumeRemainingBytes(); |
| 36 |
| 37 client.GenerateAuthenticateMessage( |
| 38 domain, username, password, hostname, net::ntlm::test::kClientChallenge, |
| 39 net::ntlm::Buffer( |
| 40 reinterpret_cast<const uint8_t*>(challenge_msg_bytes.data()), |
| 41 challenge_msg_bytes.size())); |
| 42 return 0; |
| 43 } |
OLD | NEW |