From 285c8cf9f727a6c7566b6079552c5705e61f621a Mon Sep 17 00:00:00 2001 From: Hrutvik Kanabar Date: Wed, 26 Oct 2022 14:12:43 +0000 Subject: executor: add `zlib` decompression header file Create a header file to provide a clean entrypoint `puff_zlib_to_file()`, which decompresses `zlib` data from an array to a file. This will be used for pseudo-syscalls which accept compressed data, e.g. `syz_mount_image`. The implementation uses a slightly-modified version of `puff.{c,h}`, found in the `zlib` repository. We have to be careful to ensure the copyright information from `puff.{c,h}` gets included in generated C code and C reproducers. Therefore, introduce the `//%` pattern to indicate comments which should not be removed by code generation, and use this pattern for the copyright notice. --- pkg/csource/gen.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'pkg/csource') diff --git a/pkg/csource/gen.go b/pkg/csource/gen.go index 120db74f5..80cd056ed 100644 --- a/pkg/csource/gen.go +++ b/pkg/csource/gen.go @@ -57,9 +57,12 @@ func main() { "x86_system_policy.h", } data = replaceIncludes(androidFilenames, "../../executor/android/", data) + // Remove `//` comments, but keep lines which start with `//%`. for _, remove := range []string{ - "(\n|^)\\s*//.*", - "\\s*//.*", + "(\n|^)\\s*//$", + "(\n|^)\\s*//[^%].*", + "\\s*//$", + "\\s*//[^%].*", } { data = regexp.MustCompile(remove).ReplaceAll(data, nil) } -- cgit mrf-deployment