| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <ostream> | 6 #include <ostream> |
| 7 #include <set> | 7 #include <set> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 static void CopyMessageID(PickleCracker *dst, PickleCracker *src) { | 503 static void CopyMessageID(PickleCracker *dst, PickleCracker *src) { |
| 504 memcpy(dst->mutable_payload(), src->payload(), sizeof(int)); | 504 memcpy(dst->mutable_payload(), src->payload(), sizeof(int)); |
| 505 } | 505 } |
| 506 }; | 506 }; |
| 507 | 507 |
| 508 // Redefine macros to generate fuzzing from traits declarations. | 508 // Redefine macros to generate fuzzing from traits declarations. |
| 509 // Null out all the macros that need nulling. | 509 // Null out all the macros that need nulling. |
| 510 #include "ipc/ipc_message_null_macros.h" | 510 #include "ipc/ipc_message_null_macros.h" |
| 511 | 511 |
| 512 // STRUCT declarations cause corresponding STRUCT_TRAITS declarations to occur. | 512 // STRUCT declarations cause corresponding STRUCT_TRAITS declarations to occur. |
| 513 #undef IPC_STRUCT_BEGIN | |
| 514 #undef IPC_STRUCT_BEGIN_WITH_PARENT | 513 #undef IPC_STRUCT_BEGIN_WITH_PARENT |
| 515 #undef IPC_STRUCT_MEMBER | 514 #undef IPC_STRUCT_MEMBER |
| 516 #undef IPC_STRUCT_END | 515 #undef IPC_STRUCT_END |
| 517 #define IPC_STRUCT_BEGIN_WITH_PARENT(struct_name, parent)\ | 516 #define IPC_STRUCT_BEGIN_WITH_PARENT(struct_name, parent)\ |
| 518 IPC_STRUCT_BEGIN(struct_name) | 517 IPC_STRUCT_TRAITS_BEGIN(struct_name) |
| 519 #define IPC_STRUCT_BEGIN(struct_name) IPC_STRUCT_TRAITS_BEGIN(struct_name) | |
| 520 #define IPC_STRUCT_MEMBER(type, name, ...) IPC_STRUCT_TRAITS_MEMBER(name) | 518 #define IPC_STRUCT_MEMBER(type, name, ...) IPC_STRUCT_TRAITS_MEMBER(name) |
| 521 #define IPC_STRUCT_END() IPC_STRUCT_TRAITS_END() | 519 #define IPC_STRUCT_END() IPC_STRUCT_TRAITS_END() |
| 522 | 520 |
| 523 // Set up so next include will generate fuzz trait classes. | 521 // Set up so next include will generate fuzz trait classes. |
| 524 #undef IPC_STRUCT_TRAITS_BEGIN | 522 #undef IPC_STRUCT_TRAITS_BEGIN |
| 525 #undef IPC_STRUCT_TRAITS_MEMBER | 523 #undef IPC_STRUCT_TRAITS_MEMBER |
| 526 #undef IPC_STRUCT_TRAITS_PARENT | 524 #undef IPC_STRUCT_TRAITS_PARENT |
| 527 #undef IPC_STRUCT_TRAITS_END | 525 #undef IPC_STRUCT_TRAITS_END |
| 528 #define IPC_STRUCT_TRAITS_BEGIN(struct_name) \ | 526 #define IPC_STRUCT_TRAITS_BEGIN(struct_name) \ |
| 529 template <> \ | 527 template <> \ |
| 530 struct FuzzTraits<struct_name> { \ | 528 struct FuzzTraits<struct_name> { \ |
| 531 static void Fuzz(struct_name *p, IPC::Fuzzer* fuzzer) { \ | 529 static void Fuzz(struct_name *p, IPC::Fuzzer* fuzzer) { \ |
| 532 | 530 |
| 533 #define IPC_STRUCT_TRAITS_MEMBER(name) \ | 531 #define IPC_STRUCT_TRAITS_MEMBER(name) \ |
| 534 FuzzParam(&p->name, fuzzer); | 532 FuzzParam(&p->name, fuzzer); |
| 535 | 533 |
| 536 #define IPC_STRUCT_TRAITS_PARENT(type) \ | 534 #define IPC_STRUCT_TRAITS_PARENT(type) \ |
| 537 FuzzParam(static_cast<type*>(p), fuzzer); | 535 FuzzParam(static_cast<type*>(p), fuzzer); |
| 538 | 536 |
| 539 #define IPC_STRUCT_TRAITS_END() \ | 537 #define IPC_STRUCT_TRAITS_END() \ |
| 540 } \ | 538 } \ |
| 541 }; | 539 }; |
| 542 | 540 |
| 543 #undef IPC_ENUM_TRAITS | 541 #undef IPC_ENUM_TRAITS_VALIDATE |
| 544 #define IPC_ENUM_TRAITS(enum_name) \ | 542 #define IPC_ENUM_TRAITS_VALIDATE(enum_name, validation_expression) \ |
| 545 template <> \ | 543 template <> \ |
| 546 struct FuzzTraits<enum_name> { \ | 544 struct FuzzTraits<enum_name> { \ |
| 547 static void Fuzz(enum_name* p, IPC::Fuzzer* fuzzer) { \ | 545 static void Fuzz(enum_name* p, IPC::Fuzzer* fuzzer) { \ |
| 548 FuzzParam(reinterpret_cast<int*>(p), fuzzer); \ | 546 FuzzParam(reinterpret_cast<int*>(p), fuzzer); \ |
| 549 } \ | 547 } \ |
| 550 }; | 548 }; |
| 551 | 549 |
| 552 // Bring them into existence. | 550 // Bring them into existence. |
| 553 #include "chrome/common/all_messages.h" | 551 #include "chrome/common/all_messages.h" |
| 554 #include "content/common/all_messages.h" | 552 #include "content/common/all_messages.h" |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 | 682 |
| 685 // Entry point avoiding mangled names. | 683 // Entry point avoiding mangled names. |
| 686 extern "C" { | 684 extern "C" { |
| 687 __attribute__((visibility("default"))) | 685 __attribute__((visibility("default"))) |
| 688 IPC::ChannelProxy::OutgoingMessageFilter* GetFilter(void); | 686 IPC::ChannelProxy::OutgoingMessageFilter* GetFilter(void); |
| 689 } | 687 } |
| 690 | 688 |
| 691 IPC::ChannelProxy::OutgoingMessageFilter* GetFilter(void) { | 689 IPC::ChannelProxy::OutgoingMessageFilter* GetFilter(void) { |
| 692 return &g_ipcfuzz; | 690 return &g_ipcfuzz; |
| 693 } | 691 } |
| OLD | NEW |