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

Side by Side Diff: net/ntlm/ntlm_client_fuzzer.cc

Issue 2904633002: Replace NTLMv1 implementation with a functionally equivalent one.
Patch Set: Fix uninitialized read Created 3 years, 4 months 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 unified diff | Download patch
« no previous file with comments | « net/ntlm/ntlm_client.cc ('k') | net/ntlm/ntlm_client_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 }
OLDNEW
« no previous file with comments | « net/ntlm/ntlm_client.cc ('k') | net/ntlm/ntlm_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698