| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <memory> | |
| 9 | |
| 10 #include "courgette/assembly_program.h" | |
| 11 #include "courgette/courgette.h" | 8 #include "courgette/courgette.h" |
| 12 #include "courgette/encoded_program.h" | 9 #include "courgette/courgette_flow.h" |
| 13 #include "courgette/program_detector.h" | 10 #include "courgette/region.h" |
| 14 | 11 |
| 15 // Entry point for LibFuzzer. | 12 // Entry point for LibFuzzer. |
| 16 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { | 13 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { |
| 17 std::unique_ptr<courgette::AssemblyProgram> prog; | 14 courgette::CourgetteFlow flow; |
| 18 courgette::Status status = | 15 courgette::RegionBuffer buffer(courgette::Region(data, size)); |
| 19 courgette::ParseDetectedExecutable(data, size, &prog); | 16 flow.ReadDisassemblerFromBuffer(flow.ONLY, buffer); |
| 20 if (status != courgette::C_OK) { | 17 flow.CreateAssemblyProgramFromDisassembler(flow.ONLY, false); |
| 21 return 0; | 18 flow.CreateEncodedProgramFromDisassemblerAndAssemblyProgram(flow.ONLY); |
| 22 } | 19 flow.WriteSinkStreamSetFromEncodedProgram(flow.ONLY); |
| 23 std::unique_ptr<courgette::EncodedProgram> enc_prog(prog->Encode()); | 20 // Not bothering to check |flow.failed()|. |
| 24 return 0; | 21 return 0; |
| 25 } | 22 } |
| OLD | NEW |