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

Side by Side Diff: net/base/fuzzed_data_provider.h

Issue 1929703003: fuzzers for VerifyNameMatch and VerifyNameInSubtree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use FuzzedDataProvider 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/base/fuzzed_data_provider.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_BASE_FUZZED_DATA_PROVIDER_H 5 #ifndef NET_BASE_FUZZED_DATA_PROVIDER_H
6 #define NET_BASE_FUZZED_DATA_PROVIDER_H 6 #define NET_BASE_FUZZED_DATA_PROVIDER_H
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 10 matching lines...) Expand all
21 // provide more granular access. |data| must outlive the FuzzedDataProvider. 21 // provide more granular access. |data| must outlive the FuzzedDataProvider.
22 FuzzedDataProvider(const uint8_t* data, size_t size); 22 FuzzedDataProvider(const uint8_t* data, size_t size);
23 ~FuzzedDataProvider(); 23 ~FuzzedDataProvider();
24 24
25 // Returns a StringPiece containing |length| bytes of the input data. If fewer 25 // Returns a StringPiece containing |length| bytes of the input data. If fewer
26 // than that many bytes remain, returns a shorter StringPiece containing all 26 // than that many bytes remain, returns a shorter StringPiece containing all
27 // of the data that's left. The data pointed at by the returned StringPiece 27 // of the data that's left. The data pointed at by the returned StringPiece
28 // must not be used after the FuzzedDataProvider is destroyed. 28 // must not be used after the FuzzedDataProvider is destroyed.
29 base::StringPiece ConsumeBytes(size_t bytes); 29 base::StringPiece ConsumeBytes(size_t bytes);
30 30
31 // Returns a StringPiece containing all remaining bytes of the input data.
32 // The data pointed at by the returned StringPiece must not be used after the
33 // FuzzedDataProvider is destroyed.
34 base::StringPiece ConsumeRemainingBytes();
35
31 // Returns a value from |min| to |max| inclusive, extracting a value from the 36 // Returns a value from |min| to |max| inclusive, extracting a value from the
32 // input data in some unspecified manner. Value may not be uniformly 37 // input data in some unspecified manner. Value may not be uniformly
33 // distributed in the given range. If there's no input data left, always 38 // distributed in the given range. If there's no input data left, always
34 // returns |min|. |min| must be less than or equal to |max|. 39 // returns |min|. |min| must be less than or equal to |max|.
35 uint32_t ConsumeValueInRange(uint32_t min, uint32_t max); 40 uint32_t ConsumeValueInRange(uint32_t min, uint32_t max);
36 41
37 // Returns a value with the specified number of bits of data. Returns 0 if 42 // Returns a value with the specified number of bits of data. Returns 0 if
38 // there's no input data left. |num_bits| must non-zero, and at most 32. 43 // there's no input data left. |num_bits| must non-zero, and at most 32.
39 // Basically the same as ConsumeValueInRange((1 << num_bits) - 1); 44 // Basically the same as ConsumeValueInRange((1 << num_bits) - 1);
40 uint32_t ConsumeBits(size_t num_bits); 45 uint32_t ConsumeBits(size_t num_bits);
41 46
42 // Same as ConsumeBits(1), but returns a bool. Returns false when there's no 47 // Same as ConsumeBits(1), but returns a bool. Returns false when there's no
43 // data remaining. 48 // data remaining.
44 bool ConsumeBool(); 49 bool ConsumeBool();
45 50
46 private: 51 private:
47 base::StringPiece remaining_data_; 52 base::StringPiece remaining_data_;
48 53
49 DISALLOW_COPY_AND_ASSIGN(FuzzedDataProvider); 54 DISALLOW_COPY_AND_ASSIGN(FuzzedDataProvider);
50 }; 55 };
51 56
52 } // namespace net 57 } // namespace net
53 58
54 #endif // NET_BASE_FUZZED_DATA_PROVIDER_H 59 #endif // NET_BASE_FUZZED_DATA_PROVIDER_H
OLDNEW
« no previous file with comments | « net/BUILD.gn ('k') | net/base/fuzzed_data_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698