Fuzzing OCamlFormat with AFL and Crowbar (opens in new tab)
OCamlFormat is a tool to format source code. To do so, it parses the source code to an Abstract Syntax Tree (AST) and then applies formatting rules to the AST. It can be tricky to correctly format the output. For example, say we want to format (a+b)*c. The corresponding AST will look like Apply("*", Apply ("+", Var "a", Var "b"), Var "c"). A naive formatter would look like this: let rec format = function | Var s -> s | Apply (op, e1, e2) -> Printf.sprintf "%s %s %s" (format e1) op (format e2)...
Read the original article