c_cpp Protobuf-Mutator实现的原型

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c_cpp Protobuf-Mutator实现的原型相关的知识,希望对你有一定的参考价值。

#define Proto apollo::tools::fuzz::control_message
#define use_binary false 

static void TestOneProtoInput(const apollo::tools::fuzz::control_message& arg);                                          
  using FuzzerProtoType = std::remove_const<std::remove_reference<             
      std::function<decltype(TestOneProtoInput)>::argument_type>::type>::type; 
  extern "C" size_t LLVMFuzzerCustomMutator(                                   
      uint8_t* data, size_t size, size_t max_size, unsigned int seed) {        
    using protobuf_mutator::libfuzzer::CustomProtoMutator;                     
    Proto input;                                                               
    return CustomProtoMutator(use_binary, data, size, max_size, seed, &input); 
 }                
extern "C" size_t LLVMFuzzerCustomCrossOver(                                
      const uint8_t* data1, size_t size1, const uint8_t* data2, size_t size2, 
      uint8_t* out, size_t max_out_size, unsigned int seed) {                 
    using protobuf_mutator::libfuzzer::CustomProtoCrossOver;                  
    Proto input1;                                                             
    Proto input2;                                                             
    return CustomProtoCrossOver(use_binary, data1, size1, data2, size2, out,  
                                max_out_size, seed, &input1, &input2);        
}
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { 
    using protobuf_mutator::libfuzzer::LoadProtoInput;                      
    Proto input;                                                            
    if (LoadProtoInput(use_binary, data, size, &input))                     
      TestOneProtoInput(input);                                             
    return 0;                                                               
}               
static void TestOneProtoInput(const apollo::tools::fuzz::control_message& message)
{
    apollo::control::control_fuzzer.SetUp();
    if (message.has_planning() &&
      message.planning().header().module_name() == "planning"
      && message.planning().trajectory_point().size() > 0) {
      apollo::control::control_fuzzer.FuzzTarget(
        message.pad(),
        message.localization(),
        message.planning(),
        message.chassis());
    }
}

以上是关于c_cpp Protobuf-Mutator实现的原型的主要内容,如果未能解决你的问题,请参考以下文章

c_cpp 链接列表的线性队列实现

c_cpp 替代简化的fgets实现

c_cpp 可调整大小的数组实现

c_cpp 辛格尔顿的一种实现

c_cpp C中流对象的一个​​实现

c_cpp 我的ctype.h的实现