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

Side by Side Diff: net/cert/internal/verify_name_match_fuzzer.cc

Issue 1929703003: fuzzers for VerifyNameMatch and VerifyNameInSubtree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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/BUILD.gn ('k') | net/cert/internal/verify_name_match_verifynameinsubtree_fuzzer.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 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 "net/cert/internal/verify_name_match.h"
6
7 #include <limits>
8
9 #include "net/der/input.h"
10
11 // Entry point for LibFuzzer.
12 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
13 // Use the first byte of data as a ratio to divide the rest of data into
eroman 2016/04/28 18:27:10 The problem with using a 1 byte ratio like this is
14 // two parts. If there is less than one byte, just give up.
15 if (size < 1)
16 return 0;
17 size_t split_val = data[0];
18
19 const uint8_t* remaining_data = data + 1;
20 size_t remaining_size = size - 1;
21 size_t first_part_size = remaining_size * split_val / 0xff;
22 // Sanity check. If |size| is very large the multiplication could wrap
23 // around, but |first_part_size| should still never be larger than
24 // |remaining_size|.
25 CHECK_LE(first_part_size, remaining_size);
26
27 net::der::Input in1(remaining_data, first_part_size);
28 net::der::Input in2(remaining_data + first_part_size,
29 remaining_size - first_part_size);
30 bool match = net::VerifyNameMatch(in1, in2);
31 bool reverse_order_match = net::VerifyNameMatch(in2, in1);
32 // Result should be the same regardless of argument order.
33 CHECK_EQ(match, reverse_order_match);
34 return 0;
35 }
OLDNEW
« no previous file with comments | « net/BUILD.gn ('k') | net/cert/internal/verify_name_match_verifynameinsubtree_fuzzer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698