| 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 <iostream> | 5 #include <iostream> |
| 6 #include <set> | 6 #include <set> |
| 7 #include <string> | 7 #include <string> |
| 8 #include <tuple> | 8 #include <tuple> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 | 583 |
| 584 ++g_depth; | 584 ++g_depth; |
| 585 size_t dict_length = g_depth > 3 ? 0 : RandInRange(8); | 585 size_t dict_length = g_depth > 3 ? 0 : RandInRange(8); |
| 586 for (size_t index = 0; index < dict_length; ++index) { | 586 for (size_t index = 0; index < dict_length; ++index) { |
| 587 std::string property; | 587 std::string property; |
| 588 fuzzer->FuzzString(&property); | 588 fuzzer->FuzzString(&property); |
| 589 switch (static_cast<base::Value::Type>(RandInRange(8))) { | 589 switch (static_cast<base::Value::Type>(RandInRange(8))) { |
| 590 case base::Value::Type::BOOLEAN: { | 590 case base::Value::Type::BOOLEAN: { |
| 591 bool tmp; | 591 bool tmp; |
| 592 fuzzer->FuzzBool(&tmp); | 592 fuzzer->FuzzBool(&tmp); |
| 593 p->SetWithoutPathExpansion(property, new base::Value(tmp)); | 593 p->SetWithoutPathExpansion(property, |
| 594 base::MakeUnique<base::Value>(tmp)); |
| 594 break; | 595 break; |
| 595 } | 596 } |
| 596 case base::Value::Type::INTEGER: { | 597 case base::Value::Type::INTEGER: { |
| 597 int tmp; | 598 int tmp; |
| 598 fuzzer->FuzzInt(&tmp); | 599 fuzzer->FuzzInt(&tmp); |
| 599 p->SetWithoutPathExpansion(property, new base::Value(tmp)); | 600 p->SetWithoutPathExpansion(property, |
| 601 base::MakeUnique<base::Value>(tmp)); |
| 600 break; | 602 break; |
| 601 } | 603 } |
| 602 case base::Value::Type::DOUBLE: { | 604 case base::Value::Type::DOUBLE: { |
| 603 double tmp; | 605 double tmp; |
| 604 fuzzer->FuzzDouble(&tmp); | 606 fuzzer->FuzzDouble(&tmp); |
| 605 p->SetWithoutPathExpansion(property, new base::Value(tmp)); | 607 p->SetWithoutPathExpansion(property, |
| 608 base::MakeUnique<base::Value>(tmp)); |
| 606 break; | 609 break; |
| 607 } | 610 } |
| 608 case base::Value::Type::STRING: { | 611 case base::Value::Type::STRING: { |
| 609 std::string tmp; | 612 std::string tmp; |
| 610 fuzzer->FuzzString(&tmp); | 613 fuzzer->FuzzString(&tmp); |
| 611 p->SetWithoutPathExpansion(property, new base::Value(tmp)); | 614 p->SetWithoutPathExpansion( |
| 615 property, base::MakeUnique<base::Value>(std::move(tmp))); |
| 612 break; | 616 break; |
| 613 } | 617 } |
| 614 case base::Value::Type::BINARY: { | 618 case base::Value::Type::BINARY: { |
| 615 char tmp[200]; | 619 char tmp[200]; |
| 616 size_t bin_length = RandInRange(sizeof(tmp)); | 620 size_t bin_length = RandInRange(sizeof(tmp)); |
| 617 fuzzer->FuzzData(tmp, bin_length); | 621 fuzzer->FuzzData(tmp, bin_length); |
| 618 p->SetWithoutPathExpansion( | 622 p->SetWithoutPathExpansion( |
| 619 property, base::Value::CreateWithCopiedBuffer(tmp, bin_length)); | 623 property, base::Value::CreateWithCopiedBuffer(tmp, bin_length)); |
| 620 break; | 624 break; |
| 621 } | 625 } |
| 622 case base::Value::Type::DICTIONARY: { | 626 case base::Value::Type::DICTIONARY: { |
| 623 base::DictionaryValue* tmp = new base::DictionaryValue(); | 627 auto tmp = base::MakeUnique<base::DictionaryValue>(); |
| 624 FuzzParam(tmp, fuzzer); | 628 FuzzParam(tmp.get(), fuzzer); |
| 625 p->SetWithoutPathExpansion(property, tmp); | 629 p->SetWithoutPathExpansion(property, std::move(tmp)); |
| 626 break; | 630 break; |
| 627 } | 631 } |
| 628 case base::Value::Type::LIST: { | 632 case base::Value::Type::LIST: { |
| 629 base::ListValue* tmp = new base::ListValue(); | 633 auto tmp = base::MakeUnique<base::ListValue>(); |
| 630 FuzzParam(tmp, fuzzer); | 634 FuzzParam(tmp.get(), fuzzer); |
| 631 p->SetWithoutPathExpansion(property, tmp); | 635 p->SetWithoutPathExpansion(property, std::move(tmp)); |
| 632 break; | 636 break; |
| 633 } | 637 } |
| 634 case base::Value::Type::NONE: | 638 case base::Value::Type::NONE: |
| 635 default: | 639 default: |
| 636 break; | 640 break; |
| 637 } | 641 } |
| 638 } | 642 } |
| 639 --g_depth; | 643 --g_depth; |
| 640 return true; | 644 return true; |
| 641 } | 645 } |
| (...skipping 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1822 #include "tools/ipc_fuzzer/message_lib/all_message_null_macros.h" | 1826 #include "tools/ipc_fuzzer/message_lib/all_message_null_macros.h" |
| 1823 #undef IPC_MESSAGE_DECL | 1827 #undef IPC_MESSAGE_DECL |
| 1824 #define IPC_MESSAGE_DECL(name, ...) \ | 1828 #define IPC_MESSAGE_DECL(name, ...) \ |
| 1825 (*map)[static_cast<uint32_t>(name::ID)] = FuzzerHelper<name>::Fuzz; | 1829 (*map)[static_cast<uint32_t>(name::ID)] = FuzzerHelper<name>::Fuzz; |
| 1826 | 1830 |
| 1827 void PopulateFuzzerFunctionMap(FuzzerFunctionMap* map) { | 1831 void PopulateFuzzerFunctionMap(FuzzerFunctionMap* map) { |
| 1828 #include "tools/ipc_fuzzer/message_lib/all_messages.h" | 1832 #include "tools/ipc_fuzzer/message_lib/all_messages.h" |
| 1829 } | 1833 } |
| 1830 | 1834 |
| 1831 } // namespace ipc_fuzzer | 1835 } // namespace ipc_fuzzer |
| OLD | NEW |