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

Unified Diff: net/base/fuzzed_data_provider.h

Issue 1946793002: net: Add fuzzer for HostResolverImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge, fix build 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 side-by-side diff with in-line comments
Download patch
Index: net/base/fuzzed_data_provider.h
diff --git a/net/base/fuzzed_data_provider.h b/net/base/fuzzed_data_provider.h
index 47a45061cdf248b9a2da0bd5e94fb1399f04ba6b..81fded425a233116c9fc6eb100d09e3364cc29fc 100644
--- a/net/base/fuzzed_data_provider.h
+++ b/net/base/fuzzed_data_provider.h
@@ -33,24 +33,33 @@ class FuzzedDataProvider {
// FuzzedDataProvider is destroyed.
base::StringPiece ConsumeRemainingBytes();
- // Returns an unsigned number in the range [min, max] by consuming bytes from
- // the input data. The value might not be uniformly distributed in the given
- // range. If there's no input data left, always returns |min|. |min| must be
- // less than or equal to |max|.
- uint32_t ConsumeValueInRange(uint32_t min, uint32_t max);
+ // Returns a number in the range [min, max] by consuming bytes from the input
+ // data. The value might not be uniformly distributed in the given range. If
+ // there's no input data left, always returns |min|. |min| must be less than
+ // or equal to |max|.
+ uint32_t ConsumeUint32InRange(uint32_t min, uint32_t max);
+ int ConsumeInt32InRange(int min, int max);
// Returns a bool, or false when no data remains.
bool ConsumeBool();
// Returns a uint8_t from the input or 0 if nothing remains. This is
- // equivalent to ConsumeValueInRange(0, 0xFF).
+ // equivalent to ConsumeUint32InRange(0, 0xFF).
uint8_t ConsumeUint8();
// Returns a uint16_t from the input. If fewer than 2 bytes of data remain
// will fill the most significant bytes with 0. This is equivalent to
- // ConsumeValueInRange(0, 0xFFFF).
+ // ConsumeUint32InRange(0, 0xFFFF).
uint16_t ConsumeUint16();
+ // Returns a value from |array|, consuming as many bytes as needed to do so.
+ // |array| must be a fixed-size array. Equivalent to
+ // array[ConsumeUint32InRange(sizeof(array)-1)];
+ template <typename Type, int size>
eroman 2016/06/01 01:47:21 nit: size_t -- Although I can't imagine it making
mmenke 2016/06/01 21:21:51 Done.
+ Type PickArrayEntry(Type (&array)[size]) {
mmenke 2016/05/19 19:09:46 Open to other names here. "ConsumeArrayEntry" or
eroman 2016/06/01 01:47:21 Yep this is what I was thinking. Current name is
mmenke 2016/06/01 21:21:51 I like the name much better... Actually, though,
+ return array[ConsumeUint32InRange(0, size - 1)];
+ }
+
// Reports the remaining bytes available for fuzzed input.
size_t remaining_bytes() { return remaining_data_.length(); }
« no previous file with comments | « net/BUILD.gn ('k') | net/base/fuzzed_data_provider.cc » ('j') | net/dns/dns_socket_pool.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698