aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/csource
diff options
context:
space:
mode:
authorHrutvik Kanabar <hrutvik@google.com>2022-10-26 14:12:43 +0000
committerAleksandr Nogikh <wp32pw@gmail.com>2022-11-21 11:06:14 +0100
commit285c8cf9f727a6c7566b6079552c5705e61f621a (patch)
treea8d87a874bf0f778cd3b5df2406228300244c0fb /pkg/csource
parent1360be3b26a4fe8a3ece98440df5a82253ac23ba (diff)
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.
Diffstat (limited to 'pkg/csource')
-rw-r--r--pkg/csource/gen.go7
1 files changed, 5 insertions, 2 deletions
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)
}