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

Unified Diff: base/test/fuzzed_data_provider.cc

Issue 2469813002: Add a URLRequest FTP fuzzer. (Closed)
Patch Set: Minor fixes Created 4 years, 1 month 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: base/test/fuzzed_data_provider.cc
diff --git a/base/test/fuzzed_data_provider.cc b/base/test/fuzzed_data_provider.cc
index 3045e693a75f9eee407538809731a00eee9d160f..b0c9dd6118b0fef4ef09c3bfff66bf2eb6238224 100644
--- a/base/test/fuzzed_data_provider.cc
+++ b/base/test/fuzzed_data_provider.cc
@@ -54,6 +54,22 @@ uint32_t FuzzedDataProvider::ConsumeUint32InRange(uint32_t min, uint32_t max) {
return min + result % (range + 1);
}
+std::string FuzzedDataProvider::ConsumeRandomLengthString(size_t max_length) {
+ std::string out;
+ for (size_t i = 0; i < max_length && !remaining_data_.empty(); ++i) {
+ char next = remaining_data_[0];
+ remaining_data_.remove_prefix(1);
+ if (next == '\\' && !remaining_data_.empty()) {
+ next = remaining_data_[0];
+ remaining_data_.remove_prefix(1);
+ if (next != '\\')
+ return out;
+ }
+ out += next;
+ }
+ return out;
+}
+
int FuzzedDataProvider::ConsumeInt32InRange(int min, int max) {
CHECK_LE(min, max);

Powered by Google App Engine
This is Rietveld 408576698