aboutsummaryrefslogtreecommitdiffstats
path: root/prog
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2024-08-05 14:48:58 +0200
committerAleksandr Nogikh <nogikh@google.com>2024-08-06 08:24:55 +0000
commit02d235671dbf89097f52a94a165703fa274079a2 (patch)
tree3530bdce9402487cd1bed5b7c2557b66d08f3217 /prog
parentd09987bf4245ee5e985530f65901855f39f273a3 (diff)
syz-manager: move prog helpers to the prog package
Reduce the size of syz-manager.
Diffstat (limited to 'prog')
-rw-r--r--prog/prog.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/prog/prog.go b/prog/prog.go
index 6fabaa680..de3d87778 100644
--- a/prog/prog.go
+++ b/prog/prog.go
@@ -27,6 +27,28 @@ func (p *Prog) CallName(call int) string {
return p.Calls[call].Meta.Name
}
+// OnlyContains determines whether the program only consists of the syscalls from the first argument.
+func (p *Prog) OnlyContains(syscalls map[*Syscall]bool) bool {
+ for _, c := range p.Calls {
+ if !syscalls[c.Meta] {
+ return false
+ }
+ }
+ return true
+}
+
+// FilterInplace only leaves the allowed system calls and deletes all remaining ones.
+func (p *Prog) FilterInplace(allowed map[*Syscall]bool) {
+ for i := 0; i < len(p.Calls); {
+ c := p.Calls[i]
+ if !allowed[c.Meta] {
+ p.RemoveCall(i)
+ continue
+ }
+ i++
+ }
+}
+
// These properties are parsed and serialized according to the tag and the type
// of the corresponding fields.
// IMPORTANT: keep the exact values of "key" tag for existing props unchanged,