mirror of
https://github.com/reactos/syzkaller.git
synced 2025-02-12 14:58:22 +00:00
prog: fix crash in createResource
We may be in createResource but have no resources at all because of ANYRES that are not in target.Resources. This is actually the case for some test targets. We have resources there, but syscalls that create them are disabled. In such case we crash in Intn(0). Check that we have some resources before calling Intn.
This commit is contained in:
parent
51fc038380
commit
335cf4f4fd
@ -265,7 +265,8 @@ func (r *randGen) createResource(s *state, res *ResourceType) (arg Arg, calls []
|
||||
defer func() { r.inCreateResource = false }()
|
||||
|
||||
kind := res.Desc.Name
|
||||
if r.oneOf(1000) {
|
||||
// We may have no resources, but still be in createResource due to ANYRES.
|
||||
if len(r.target.resourceMap) != 0 && r.oneOf(1000) {
|
||||
// Spoof resource subkind.
|
||||
var all []string
|
||||
for kind1 := range r.target.resourceMap {
|
||||
@ -273,6 +274,10 @@ func (r *randGen) createResource(s *state, res *ResourceType) (arg Arg, calls []
|
||||
all = append(all, kind1)
|
||||
}
|
||||
}
|
||||
if len(all) == 0 {
|
||||
panic(fmt.Sprintf("got no spoof resources for %v in %v/%v",
|
||||
kind, r.target.OS, r.target.Arch))
|
||||
}
|
||||
sort.Strings(all)
|
||||
kind = all[r.Intn(len(all))]
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user