Skip to content

Latest commit

 

History

History
34 lines (25 loc) · 1.42 KB

README.md

File metadata and controls

34 lines (25 loc) · 1.42 KB

A Custom Crossover Example

Overview

This example is a reimplementation of Erik Rigtorp's floating point summation fuzzing example in the Rust bindings for LibFuzzer, provided by this crate. In this particular example, Erik uses both a custom mutator, and a custom crossover function, which provides a well-documented, complex code example.

Implementation

This is mostly a one-to-one rewrite of the C++ code in the blog post, with the big difference being the method of converting the raw bytes that is exposed to the custom functions, into the decoded double-precision floating-point values. Where in C++ we can simply do:

uint8_t *Data = ...;
size_t Size = ...;
double *begin = (double *)Data;
double *end = (double *)Data + Size / sizeof(double);

In Rust, however, the task seems a bit more complex due to strictness on alignment:

So the casting of Data in the blog post's C++ are now slice::align_to{_mut} calls