12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- #ifndef TOOLS_IPC_FUZZER_MUTATE_FUZZER_H_
- #define TOOLS_IPC_FUZZER_MUTATE_FUZZER_H_
- #include <stddef.h>
- #include <stdint.h>
- #include <memory>
- #include <string>
- #include <unordered_map>
- #include <vector>
- #include "base/strings/string_util.h"
- #include "ipc/ipc_message.h"
- namespace ipc_fuzzer {
- class Fuzzer {
- public:
-
- virtual void FuzzBool(bool* value) = 0;
- virtual void FuzzInt(int* value) = 0;
- virtual void FuzzLong(long* value) = 0;
- virtual void FuzzSize(size_t* value) = 0;
- virtual void FuzzUChar(unsigned char* value) = 0;
- virtual void FuzzWChar(wchar_t* value) = 0;
- virtual void FuzzUInt16(uint16_t* value) = 0;
- virtual void FuzzUInt32(uint32_t* value) = 0;
- virtual void FuzzInt64(int64_t* value) = 0;
- virtual void FuzzUInt64(uint64_t* value) = 0;
- virtual void FuzzFloat(float* value) = 0;
- virtual void FuzzDouble(double *value) = 0;
- virtual void FuzzString(std::string* value) = 0;
- virtual void FuzzString16(base::string16* value) = 0;
- virtual void FuzzData(char* data, int length) = 0;
- virtual void FuzzBytes(void* data, int data_len) = 0;
-
-
- virtual bool ShouldGenerate();
- };
- class NoOpFuzzer : public Fuzzer {
- public:
- NoOpFuzzer() {}
- virtual ~NoOpFuzzer() {}
- void FuzzBool(bool* value) override {}
- void FuzzInt(int* value) override {}
- void FuzzLong(long* value) override {}
- void FuzzSize(size_t* value) override {}
- void FuzzUChar(unsigned char* value) override {}
- void FuzzWChar(wchar_t* value) override {}
- void FuzzUInt16(uint16_t* value) override {}
- void FuzzUInt32(uint32_t* value) override {}
- void FuzzInt64(int64_t* value) override {}
- void FuzzUInt64(uint64_t* value) override {}
- void FuzzFloat(float* value) override {}
- void FuzzDouble(double* value) override {}
- void FuzzString(std::string* value) override {}
- void FuzzString16(base::string16* value) override {}
- void FuzzData(char* data, int length) override {}
- void FuzzBytes(void* data, int data_len) override {}
- };
- using FuzzerFunction = std::unique_ptr<IPC::Message> (*)(IPC::Message*,
- Fuzzer*);
- using FuzzerFunctionMap = std::unordered_map<uint32_t, FuzzerFunction>;
- void PopulateFuzzerFunctionMap(FuzzerFunctionMap* map);
- using FuzzerFunctionVector = std::vector<FuzzerFunction>;
- void PopulateFuzzerFunctionVector(FuzzerFunctionVector* function_vector);
- extern FuzzerFunctionVector g_function_vector;
- }
- #endif
|