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)) | 1044 |
| 1045 // |type| enum is not validated on de-serialization, so pick random value. |
| 1046 if (!GenerateParam(reinterpret_cast<int *>(&info.type), generator)) |
1045 return false; | 1047 return false; |
1046 content::WebCursor::CursorInfo info(type); | |
1047 | |
1048 // Omitting |externalHandle| since it is not serialized. | |
1049 if (!GenerateParam(&info.hotspot, generator)) | 1048 if (!GenerateParam(&info.hotspot, generator)) |
1050 return false; | 1049 return false; |
1051 if (!GenerateParam(&info.image_scale_factor, generator)) | 1050 if (!GenerateParam(&info.image_scale_factor, generator)) |
1052 return false; | 1051 return false; |
1053 if (!GenerateParam(&info.custom_image, generator)) | 1052 if (!GenerateParam(&info.custom_image, generator)) |
1054 return false; | 1053 return false; |
| 1054 // Omitting |externalHandle| since it is not serialized. |
| 1055 |
| 1056 // Scale factor is expected to be greater than 0, otherwise we hit |
| 1057 // a check failure. |
| 1058 info.image_scale_factor = fabs(info.image_scale_factor) + 0.001; |
| 1059 |
1055 *p = content::WebCursor(info); | 1060 *p = content::WebCursor(info); |
1056 return true; | 1061 return true; |
1057 } | 1062 } |
1058 }; | 1063 }; |
1059 | 1064 |
1060 template <> | 1065 template <> |
1061 struct GenerateTraits<ContentSettingsPattern> { | 1066 struct GenerateTraits<ContentSettingsPattern> { |
1062 static bool Generate(ContentSettingsPattern* p, Generator* generator) { | 1067 static bool Generate(ContentSettingsPattern* p, Generator* generator) { |
1063 // TODO(mbarbella): This can crash if a pattern is generated from a random | 1068 // 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. | 1069 // 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; | 1288 random_url = std::string("file://") + random_url; |
1284 else if (selector == 2) | 1289 else if (selector == 2) |
1285 random_url = std::string("javascript:") + random_url; | 1290 random_url = std::string("javascript:") + random_url; |
1286 else if (selector == 2) | 1291 else if (selector == 2) |
1287 random_url = std::string("data:") + random_url; | 1292 random_url = std::string("data:") + random_url; |
1288 *p = GURL(random_url); | 1293 *p = GURL(random_url); |
1289 return true; | 1294 return true; |
1290 } | 1295 } |
1291 }; | 1296 }; |
1292 | 1297 |
| 1298 #if defined(OS_WIN) |
| 1299 template <> |
| 1300 struct GenerateTraits<HWND> { |
| 1301 static bool Generate(HWND* p, Generator* generator) { |
| 1302 // TODO(aarya): This should actually generate something. |
| 1303 return true; |
| 1304 } |
| 1305 }; |
| 1306 #endif |
| 1307 |
1293 template <> | 1308 template <> |
1294 struct GenerateTraits<IPC::Message> { | 1309 struct GenerateTraits<IPC::Message> { |
1295 static bool Generate(IPC::Message *p, Generator* generator) { | 1310 static bool Generate(IPC::Message *p, Generator* generator) { |
1296 if (g_function_vector.empty()) | 1311 if (g_function_vector.empty()) |
1297 return false; | 1312 return false; |
1298 size_t index = RandInRange(g_function_vector.size()); | 1313 size_t index = RandInRange(g_function_vector.size()); |
1299 IPC::Message* ipc_message = (*g_function_vector[index])(generator); | 1314 IPC::Message* ipc_message = (*g_function_vector[index])(generator); |
1300 if (!ipc_message) | 1315 if (!ipc_message) |
1301 return false; | 1316 return false; |
1302 p = ipc_message; | 1317 p = ipc_message; |
(...skipping 20 matching lines...) Expand all Loading... |
1323 p->pipe = IPC::ChannelHandle::PipeHandle(fake_handle); | 1338 p->pipe = IPC::ChannelHandle::PipeHandle(fake_handle); |
1324 return true; | 1339 return true; |
1325 #elif defined(OS_POSIX) | 1340 #elif defined(OS_POSIX) |
1326 return | 1341 return |
1327 GenerateParam(&p->name, generator) && | 1342 GenerateParam(&p->name, generator) && |
1328 GenerateParam(&p->socket, generator); | 1343 GenerateParam(&p->socket, generator); |
1329 #endif | 1344 #endif |
1330 } | 1345 } |
1331 }; | 1346 }; |
1332 | 1347 |
| 1348 #if defined(OS_WIN) |
| 1349 template <> |
| 1350 struct GenerateTraits<LOGFONT> { |
| 1351 static bool Generate(LOGFONT* p, Generator* generator) { |
| 1352 // TODO(aarya): This should actually generate something. |
| 1353 return true; |
| 1354 } |
| 1355 }; |
| 1356 #endif |
| 1357 |
1333 template <> | 1358 template <> |
1334 struct GenerateTraits<media::AudioParameters> { | 1359 struct GenerateTraits<media::AudioParameters> { |
1335 static bool Generate(media::AudioParameters* p, Generator* generator) { | 1360 static bool Generate(media::AudioParameters* p, Generator* generator) { |
1336 int format; | 1361 int format; |
1337 int channel_layout; | 1362 int channel_layout; |
1338 int sample_rate; | 1363 int sample_rate; |
1339 int bits_per_sample; | 1364 int bits_per_sample; |
1340 int frames_per_buffer; | 1365 int frames_per_buffer; |
1341 int channels; | 1366 int channels; |
1342 int effects; | 1367 int effects; |
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2064 return EXIT_FAILURE; | 2089 return EXIT_FAILURE; |
2065 | 2090 |
2066 return EXIT_SUCCESS; | 2091 return EXIT_SUCCESS; |
2067 } | 2092 } |
2068 | 2093 |
2069 } // namespace ipc_fuzzer | 2094 } // namespace ipc_fuzzer |
2070 | 2095 |
2071 int main(int argc, char** argv) { | 2096 int main(int argc, char** argv) { |
2072 return ipc_fuzzer::GenerateMain(argc, argv); | 2097 return ipc_fuzzer::GenerateMain(argc, argv); |
2073 } | 2098 } |
OLD | NEW |