Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef TOOLS_IPC_FUZZER_MUTATE_FUZZER_H_ | |
| 6 #define TOOLS_IPC_FUZZER_MUTATE_FUZZER_H_ | |
| 7 | |
| 8 #include <set> | |
|
inferno
2015/03/16 18:56:34
this looks unused ?
| |
| 9 #include <string> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "base/basictypes.h" | |
| 13 #include "base/strings/string_util.h" | |
| 14 #include "ipc/ipc_message.h" | |
| 15 #include "tools/ipc_fuzzer/message_lib/message_file.h" | |
| 16 | |
| 17 namespace ipc_fuzzer { | |
| 18 | |
| 19 // Interface implemented by those who generate basic types. The types all | |
| 20 // correspond to the types which a pickle from base/pickle.h can pickle, | |
| 21 // plus the floating point types. | |
| 22 class Fuzzer { | |
| 23 public: | |
| 24 // Functions for various data types. | |
| 25 virtual void FuzzBool(bool* value) = 0; | |
| 26 virtual void FuzzInt(int* value) = 0; | |
| 27 virtual void FuzzLong(long* value) = 0; | |
| 28 virtual void FuzzSize(size_t* value) = 0; | |
| 29 virtual void FuzzUChar(unsigned char* value) = 0; | |
| 30 virtual void FuzzWChar(wchar_t* value) = 0; | |
| 31 virtual void FuzzUInt16(uint16* value) = 0; | |
| 32 virtual void FuzzUInt32(uint32* value) = 0; | |
| 33 virtual void FuzzInt64(int64* value) = 0; | |
| 34 virtual void FuzzUInt64(uint64* value) = 0; | |
| 35 virtual void FuzzFloat(float* value) = 0; | |
| 36 virtual void FuzzDouble(double *value) = 0; | |
| 37 virtual void FuzzString(std::string* value) = 0; | |
| 38 virtual void FuzzString16(base::string16* value) = 0; | |
| 39 virtual void FuzzData(char* data, int length) = 0; | |
| 40 virtual void FuzzBytes(void* data, int data_len) = 0; | |
| 41 | |
| 42 // Used to determine if a completely new value should be generated for | |
| 43 // certain types instead of attempting to modify the existing one. | |
| 44 virtual bool ShouldGenerate(); | |
| 45 }; | |
| 46 | |
| 47 class NoOpFuzzer : public Fuzzer { | |
| 48 public: | |
| 49 NoOpFuzzer() {} | |
| 50 virtual ~NoOpFuzzer() {} | |
| 51 | |
| 52 void FuzzBool(bool* value) override {} | |
| 53 void FuzzInt(int* value) override {} | |
| 54 void FuzzLong(long* value) override {} | |
| 55 void FuzzSize(size_t* value) override {} | |
| 56 void FuzzUChar(unsigned char* value) override {} | |
| 57 void FuzzWChar(wchar_t* value) override {} | |
| 58 void FuzzUInt16(uint16* value) override {} | |
| 59 void FuzzUInt32(uint32* value) override {} | |
| 60 void FuzzInt64(int64* value) override {} | |
| 61 void FuzzUInt64(uint64* value) override {} | |
| 62 void FuzzFloat(float* value) override {} | |
| 63 void FuzzDouble(double* value) override {} | |
| 64 void FuzzString(std::string* value) override {} | |
| 65 void FuzzString16(base::string16* value) override {} | |
| 66 void FuzzData(char* data, int length) override {} | |
| 67 void FuzzBytes(void* data, int data_len) override {} | |
| 68 }; | |
| 69 | |
| 70 typedef IPC::Message* (*FuzzerFunction)(IPC::Message*, Fuzzer*); | |
| 71 typedef std::vector<FuzzerFunction> FuzzerFunctionVector; | |
|
inferno
2015/03/16 18:56:34
maybe club 71,72 with 74,75. also add comment expl
| |
| 72 typedef base::hash_map<uint32, FuzzerFunction> FuzzerFunctionMap; | |
| 73 | |
| 74 void PopulateFuzzerFunctionMap(FuzzerFunctionMap* map); | |
| 75 void PopulateFuzzerFunctionVector(FuzzerFunctionVector* function_vector); | |
| 76 | |
| 77 extern FuzzerFunctionVector g_function_vector; | |
|
inferno
2015/03/16 18:56:34
comment on use of this.
| |
| 78 | |
| 79 } // namespace ipc_fuzzer | |
| 80 | |
| 81 #endif // TOOLS_IPC_FUZZER_MUTATE_FUZZER_H_ | |
| OLD | NEW |