From ee8e09bccf73fa2b494e7e4a706a5ca5523f8eac Mon Sep 17 00:00:00 2001 From: Ian Johnson Date: Mon, 16 Sep 2024 19:57:53 -0400 Subject: [PATCH] build: make fuzzing work on 0.13.0 and master --- README.md | 8 ++++++++ fuzz/build.zig | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 88a5af4..2a0aa7d 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,14 @@ tests within. Due to features missing in the current parser implementation (DTD support), many tests are currently skipped. At the time of writing, 250 tests pass, and 924 are skipped due to unsupported features. +## Fuzzing + +There is a fuzzing sub-project in the `fuzz` directory using +https://github.com/kristoff-it/zig-afl-kit. If running on Zig 0.13.0, an extra +step needs to be taken to make the fuzzing more effective: +https://github.com/kristoff-it/zig-afl-kit/blob/main/README.md#-------important------- +On Zig master, this is not needed. + ## License zig-xml is free software, released under the [Zero Clause BSD diff --git a/fuzz/build.zig b/fuzz/build.zig index 7d8bfc4..f4e6b44 100644 --- a/fuzz/build.zig +++ b/fuzz/build.zig @@ -17,7 +17,7 @@ pub fn build(b: *std.Build) void { }); afl_obj.root_module.stack_check = false; afl_obj.root_module.link_libc = true; - //afl_obj.root_module.fuzz = true; + if (@hasField(@TypeOf(afl_obj.root_module), "fuzz")) afl_obj.root_module.fuzz = true; afl_obj.root_module.addImport("xml", xml.module("xml")); const afl_exe = afl.addInstrumentedExe(b, target, .Debug, afl_obj);