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->SetBooleanWithoutPathExpansion(property, tmp); |
594 break; | 594 break; |
595 } | 595 } |
596 case base::Value::Type::INTEGER: { | 596 case base::Value::Type::INTEGER: { |
597 int tmp; | 597 int tmp; |
598 fuzzer->FuzzInt(&tmp); | 598 fuzzer->FuzzInt(&tmp); |
599 p->SetWithoutPathExpansion(property, new base::Value(tmp)); | 599 p->SetIntegerWithoutPathExpansion(property, tmp); |
600 break; | 600 break; |
601 } | 601 } |
602 case base::Value::Type::DOUBLE: { | 602 case base::Value::Type::DOUBLE: { |
603 double tmp; | 603 double tmp; |
604 fuzzer->FuzzDouble(&tmp); | 604 fuzzer->FuzzDouble(&tmp); |
605 p->SetWithoutPathExpansion(property, new base::Value(tmp)); | 605 p->SetDoubleWithoutPathExpansion(property, tmp); |
606 break; | 606 break; |
607 } | 607 } |
608 case base::Value::Type::STRING: { | 608 case base::Value::Type::STRING: { |
609 std::string tmp; | 609 std::string tmp; |
610 fuzzer->FuzzString(&tmp); | 610 fuzzer->FuzzString(&tmp); |
611 p->SetWithoutPathExpansion(property, new base::Value(tmp)); | 611 p->SetStringWithoutPathExpansion(property, tmp); |
612 break; | 612 break; |
613 } | 613 } |
614 case base::Value::Type::BINARY: { | 614 case base::Value::Type::BINARY: { |
615 char tmp[200]; | 615 char tmp[200]; |
616 size_t bin_length = RandInRange(sizeof(tmp)); | 616 size_t bin_length = RandInRange(sizeof(tmp)); |
617 fuzzer->FuzzData(tmp, bin_length); | 617 fuzzer->FuzzData(tmp, bin_length); |
618 p->SetWithoutPathExpansion( | 618 p->SetWithoutPathExpansion( |
619 property, base::Value::CreateWithCopiedBuffer(tmp, bin_length)); | 619 property, base::Value::CreateWithCopiedBuffer(tmp, bin_length)); |
620 break; | 620 break; |
621 } | 621 } |
622 case base::Value::Type::DICTIONARY: { | 622 case base::Value::Type::DICTIONARY: { |
623 base::DictionaryValue* tmp = new base::DictionaryValue(); | 623 auto tmp = base::MakeUnique<base::DictionaryValue>(); |
624 FuzzParam(tmp, fuzzer); | 624 FuzzParam(tmp.get(), fuzzer); |
625 p->SetWithoutPathExpansion(property, tmp); | 625 p->SetWithoutPathExpansion(property, std::move(tmp)); |
626 break; | 626 break; |
627 } | 627 } |
628 case base::Value::Type::LIST: { | 628 case base::Value::Type::LIST: { |
629 base::ListValue* tmp = new base::ListValue(); | 629 auto tmp = base::MakeUnique<base::ListValue>(); |
630 FuzzParam(tmp, fuzzer); | 630 FuzzParam(tmp.get(), fuzzer); |
631 p->SetWithoutPathExpansion(property, tmp); | 631 p->SetWithoutPathExpansion(property, std::move(tmp)); |
632 break; | 632 break; |
633 } | 633 } |
634 case base::Value::Type::NONE: | 634 case base::Value::Type::NONE: |
635 default: | 635 default: |
636 break; | 636 break; |
637 } | 637 } |
638 } | 638 } |
639 --g_depth; | 639 --g_depth; |
640 return true; | 640 return true; |
641 } | 641 } |
(...skipping 1183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1825 #include "tools/ipc_fuzzer/message_lib/all_message_null_macros.h" | 1825 #include "tools/ipc_fuzzer/message_lib/all_message_null_macros.h" |
1826 #undef IPC_MESSAGE_DECL | 1826 #undef IPC_MESSAGE_DECL |
1827 #define IPC_MESSAGE_DECL(name, ...) \ | 1827 #define IPC_MESSAGE_DECL(name, ...) \ |
1828 (*map)[static_cast<uint32_t>(name::ID)] = FuzzerHelper<name>::Fuzz; | 1828 (*map)[static_cast<uint32_t>(name::ID)] = FuzzerHelper<name>::Fuzz; |
1829 | 1829 |
1830 void PopulateFuzzerFunctionMap(FuzzerFunctionMap* map) { | 1830 void PopulateFuzzerFunctionMap(FuzzerFunctionMap* map) { |
1831 #include "tools/ipc_fuzzer/message_lib/all_messages.h" | 1831 #include "tools/ipc_fuzzer/message_lib/all_messages.h" |
1832 } | 1832 } |
1833 | 1833 |
1834 } // namespace ipc_fuzzer | 1834 } // namespace ipc_fuzzer |
OLD | NEW |