OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <stdlib.h> | 5 #include <stdlib.h> |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iostream> | 8 #include <iostream> |
9 #include <ostream> | 9 #include <ostream> |
10 #include <set> | 10 #include <set> |
(...skipping 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1033 } | 1033 } |
1034 } | 1034 } |
1035 p->set_gesture_params(gesture_params.Pass()); | 1035 p->set_gesture_params(gesture_params.Pass()); |
1036 return true; | 1036 return true; |
1037 } | 1037 } |
1038 }; | 1038 }; |
1039 | 1039 |
1040 template <> | 1040 template <> |
1041 struct GenerateTraits<content::WebCursor> { | 1041 struct GenerateTraits<content::WebCursor> { |
1042 static bool Generate(content::WebCursor* p, Generator* generator) { | 1042 static bool Generate(content::WebCursor* p, Generator* generator) { |
1043 blink::WebCursorInfo::Type type; | 1043 content::WebCursor::CursorInfo info; |
1044 if (!GenerateParam(&type, generator)) | |
1045 return false; | |
1046 content::WebCursor::CursorInfo info(type); | |
1047 | 1044 |
1048 // Omitting |externalHandle| since it is not serialized. | 1045 info.type = (blink::WebCursorInfo::Type)(RandInRange(44)); |
Martin Barbella
2015/02/18 20:08:02
Can we use the last type + 1 here instead of this?
Tom Sepez
2015/02/18 20:17:11
We'd like to stick out-of-range values here, too.
| |
1049 if (!GenerateParam(&info.hotspot, generator)) | 1046 if (!GenerateParam(&info.hotspot, generator)) |
1050 return false; | 1047 return false; |
1051 if (!GenerateParam(&info.image_scale_factor, generator)) | 1048 if (!GenerateParam(&info.image_scale_factor, generator)) |
1052 return false; | 1049 return false; |
1053 if (!GenerateParam(&info.custom_image, generator)) | 1050 if (!GenerateParam(&info.custom_image, generator)) |
1054 return false; | 1051 return false; |
1052 // Omitting |externalHandle| since it is not serialized. | |
1053 | |
1054 // Scale factor is expected to be greater than 0, otherwise we hit | |
1055 // a check failure. | |
1056 info.image_scale_factor = fabs(info.image_scale_factor) + 0.001; | |
1057 | |
1055 *p = content::WebCursor(info); | 1058 *p = content::WebCursor(info); |
1056 return true; | 1059 return true; |
1057 } | 1060 } |
1058 }; | 1061 }; |
1059 | 1062 |
1060 template <> | 1063 template <> |
1061 struct GenerateTraits<ContentSettingsPattern> { | 1064 struct GenerateTraits<ContentSettingsPattern> { |
1062 static bool Generate(ContentSettingsPattern* p, Generator* generator) { | 1065 static bool Generate(ContentSettingsPattern* p, Generator* generator) { |
1063 // TODO(mbarbella): This can crash if a pattern is generated from a random | 1066 // TODO(mbarbella): This can crash if a pattern is generated from a random |
1064 // string. We could carefully generate a pattern or fix pattern generation. | 1067 // string. We could carefully generate a pattern or fix pattern generation. |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1283 random_url = std::string("file://") + random_url; | 1286 random_url = std::string("file://") + random_url; |
1284 else if (selector == 2) | 1287 else if (selector == 2) |
1285 random_url = std::string("javascript:") + random_url; | 1288 random_url = std::string("javascript:") + random_url; |
1286 else if (selector == 2) | 1289 else if (selector == 2) |
1287 random_url = std::string("data:") + random_url; | 1290 random_url = std::string("data:") + random_url; |
1288 *p = GURL(random_url); | 1291 *p = GURL(random_url); |
1289 return true; | 1292 return true; |
1290 } | 1293 } |
1291 }; | 1294 }; |
1292 | 1295 |
1296 #if defined(OS_WIN) | |
1297 template <> | |
1298 struct GenerateTraits<HWND> { | |
1299 static bool Generate(HWND* p, Generator* generator) { | |
1300 // TODO(aarya): This should actually generate something. | |
1301 return true; | |
1302 } | |
1303 }; | |
1304 #endif | |
1305 | |
1293 template <> | 1306 template <> |
1294 struct GenerateTraits<IPC::Message> { | 1307 struct GenerateTraits<IPC::Message> { |
1295 static bool Generate(IPC::Message *p, Generator* generator) { | 1308 static bool Generate(IPC::Message *p, Generator* generator) { |
1296 if (g_function_vector.empty()) | 1309 if (g_function_vector.empty()) |
1297 return false; | 1310 return false; |
1298 size_t index = RandInRange(g_function_vector.size()); | 1311 size_t index = RandInRange(g_function_vector.size()); |
1299 IPC::Message* ipc_message = (*g_function_vector[index])(generator); | 1312 IPC::Message* ipc_message = (*g_function_vector[index])(generator); |
1300 if (!ipc_message) | 1313 if (!ipc_message) |
1301 return false; | 1314 return false; |
1302 p = ipc_message; | 1315 p = ipc_message; |
(...skipping 20 matching lines...) Expand all Loading... | |
1323 p->pipe = IPC::ChannelHandle::PipeHandle(fake_handle); | 1336 p->pipe = IPC::ChannelHandle::PipeHandle(fake_handle); |
1324 return true; | 1337 return true; |
1325 #elif defined(OS_POSIX) | 1338 #elif defined(OS_POSIX) |
1326 return | 1339 return |
1327 GenerateParam(&p->name, generator) && | 1340 GenerateParam(&p->name, generator) && |
1328 GenerateParam(&p->socket, generator); | 1341 GenerateParam(&p->socket, generator); |
1329 #endif | 1342 #endif |
1330 } | 1343 } |
1331 }; | 1344 }; |
1332 | 1345 |
1346 #if defined(OS_WIN) | |
1347 template <> | |
1348 struct GenerateTraits<LOGFONT> { | |
1349 static bool Generate(LOGFONT* p, Generator* generator) { | |
1350 // TODO(aarya): This should actually generate something. | |
1351 return true; | |
1352 } | |
1353 }; | |
1354 #endif | |
1355 | |
1333 template <> | 1356 template <> |
1334 struct GenerateTraits<media::AudioParameters> { | 1357 struct GenerateTraits<media::AudioParameters> { |
1335 static bool Generate(media::AudioParameters* p, Generator* generator) { | 1358 static bool Generate(media::AudioParameters* p, Generator* generator) { |
1336 int format; | 1359 int format; |
1337 int channel_layout; | 1360 int channel_layout; |
1338 int sample_rate; | 1361 int sample_rate; |
1339 int bits_per_sample; | 1362 int bits_per_sample; |
1340 int frames_per_buffer; | 1363 int frames_per_buffer; |
1341 int channels; | 1364 int channels; |
1342 int effects; | 1365 int effects; |
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2064 return EXIT_FAILURE; | 2087 return EXIT_FAILURE; |
2065 | 2088 |
2066 return EXIT_SUCCESS; | 2089 return EXIT_SUCCESS; |
2067 } | 2090 } |
2068 | 2091 |
2069 } // namespace ipc_fuzzer | 2092 } // namespace ipc_fuzzer |
2070 | 2093 |
2071 int main(int argc, char** argv) { | 2094 int main(int argc, char** argv) { |
2072 return ipc_fuzzer::GenerateMain(argc, argv); | 2095 return ipc_fuzzer::GenerateMain(argc, argv); |
2073 } | 2096 } |
OLD | NEW |