OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include <algorithm> | 5 #include <algorithm> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/basictypes.h" | |
9 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
11 #include "tools/ipc_fuzzer/fuzzer/mutator.h" | 10 #include "tools/ipc_fuzzer/fuzzer/mutator.h" |
12 #include "tools/ipc_fuzzer/fuzzer/rand_util.h" | 11 #include "tools/ipc_fuzzer/fuzzer/rand_util.h" |
13 | 12 |
14 namespace ipc_fuzzer { | 13 namespace ipc_fuzzer { |
15 | 14 |
16 template <typename T> | 15 template <typename T> |
17 void FuzzIntegralType(T* value, unsigned int frequency) { | 16 void FuzzIntegralType(T* value, unsigned int frequency) { |
18 if (RandEvent(frequency)) { | 17 if (RandEvent(frequency)) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 } | 56 } |
58 | 57 |
59 void Mutator::FuzzUChar(unsigned char* value) { | 58 void Mutator::FuzzUChar(unsigned char* value) { |
60 FuzzIntegralType<unsigned char>(value, frequency_); | 59 FuzzIntegralType<unsigned char>(value, frequency_); |
61 } | 60 } |
62 | 61 |
63 void Mutator::FuzzWChar(wchar_t* value) { | 62 void Mutator::FuzzWChar(wchar_t* value) { |
64 FuzzIntegralType<wchar_t>(value, frequency_); | 63 FuzzIntegralType<wchar_t>(value, frequency_); |
65 } | 64 } |
66 | 65 |
67 void Mutator::FuzzUInt16(uint16* value) { | 66 void Mutator::FuzzUInt16(uint16_t* value) { |
68 FuzzIntegralType<uint16>(value, frequency_); | 67 FuzzIntegralType<uint16_t>(value, frequency_); |
69 } | 68 } |
70 | 69 |
71 void Mutator::FuzzUInt32(uint32* value) { | 70 void Mutator::FuzzUInt32(uint32_t* value) { |
72 FuzzIntegralType<uint32>(value, frequency_); | 71 FuzzIntegralType<uint32_t>(value, frequency_); |
73 } | 72 } |
74 | 73 |
75 void Mutator::FuzzInt64(int64* value) { | 74 void Mutator::FuzzInt64(int64_t* value) { |
76 FuzzIntegralType<int64>(value, frequency_); | 75 FuzzIntegralType<int64_t>(value, frequency_); |
77 } | 76 } |
78 | 77 |
79 void Mutator::FuzzUInt64(uint64* value) { | 78 void Mutator::FuzzUInt64(uint64_t* value) { |
80 FuzzIntegralType<uint64>(value, frequency_); | 79 FuzzIntegralType<uint64_t>(value, frequency_); |
81 } | 80 } |
82 | 81 |
83 void Mutator::FuzzFloat(float* value) { | 82 void Mutator::FuzzFloat(float* value) { |
84 if (RandEvent(frequency_)) | 83 if (RandEvent(frequency_)) |
85 *value = RandDouble(); | 84 *value = RandDouble(); |
86 } | 85 } |
87 | 86 |
88 void Mutator::FuzzDouble(double* value) { | 87 void Mutator::FuzzDouble(double* value) { |
89 if (RandEvent(frequency_)) | 88 if (RandEvent(frequency_)) |
90 *value = RandDouble(); | 89 *value = RandDouble(); |
(...skipping 21 matching lines...) Expand all Loading... |
112 FuzzData(static_cast<char*>(data), data_len); | 111 FuzzData(static_cast<char*>(data), data_len); |
113 } | 112 } |
114 | 113 |
115 bool Mutator::ShouldGenerate() { | 114 bool Mutator::ShouldGenerate() { |
116 // TODO(mbarbella): With a low probability, allow something to be fully | 115 // TODO(mbarbella): With a low probability, allow something to be fully |
117 // rewritten while mutating instead of always changing the existing value. | 116 // rewritten while mutating instead of always changing the existing value. |
118 return false; | 117 return false; |
119 } | 118 } |
120 | 119 |
121 } // namespace ipc_fuzzer | 120 } // namespace ipc_fuzzer |
OLD | NEW |