mirror of
https://github.com/reactos/syzkaller.git
synced 2025-02-16 01:28:33 +00:00
pkg/csource: sort sys/types.h to the top on FreeBSD
sys/types.h is a special header that is required by many other system headers on FreeBSD.
This commit is contained in:
parent
2eb2cd93e0
commit
c08c1cd05c
@ -17,7 +17,9 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
linux = "linux"
|
||||
linux = "linux"
|
||||
freebsd = "freebsd"
|
||||
openbsd = "openbsd"
|
||||
|
||||
sandboxNone = "none"
|
||||
sandboxSetuid = "setuid"
|
||||
|
@ -445,19 +445,24 @@ func (ctx *context) hoistIncludes(result []byte) []byte {
|
||||
}
|
||||
result = includeRe.ReplaceAll(result, nil)
|
||||
// Certain linux and bsd headers are broken and go to the bottom.
|
||||
var sorted, sortedBottom []string
|
||||
var sorted, sortedBottom, sortedTop []string
|
||||
for include := range includes {
|
||||
if strings.Contains(include, "<linux/") {
|
||||
sortedBottom = append(sortedBottom, include)
|
||||
} else if strings.Contains(include, "<netinet/if_ether.h>") {
|
||||
sortedBottom = append(sortedBottom, include)
|
||||
} else if ctx.target.OS == freebsd && strings.Contains(include, "<sys/types.h>") {
|
||||
sortedTop = append(sortedTop, include)
|
||||
} else {
|
||||
sorted = append(sorted, include)
|
||||
}
|
||||
}
|
||||
sort.Strings(sortedTop)
|
||||
sort.Strings(sorted)
|
||||
sort.Strings(sortedBottom)
|
||||
newResult := append([]byte{}, result[:includesStart]...)
|
||||
newResult = append(newResult, strings.Join(sortedTop, "")...)
|
||||
newResult = append(newResult, '\n')
|
||||
newResult = append(newResult, strings.Join(sorted, "")...)
|
||||
newResult = append(newResult, '\n')
|
||||
newResult = append(newResult, strings.Join(sortedBottom, "")...)
|
||||
|
@ -102,7 +102,7 @@ func (opts Options) checkLinuxOnly(OS string) error {
|
||||
if OS == linux {
|
||||
return nil
|
||||
}
|
||||
if opts.EnableTun && !(OS == "openbsd" || OS == "freebsd") {
|
||||
if opts.EnableTun && !(OS == openbsd || OS == freebsd) {
|
||||
return fmt.Errorf("EnableTun is not supported on %v", OS)
|
||||
}
|
||||
if opts.EnableNetDev {
|
||||
@ -118,7 +118,7 @@ func (opts Options) checkLinuxOnly(OS string) error {
|
||||
return fmt.Errorf("EnableBinfmtMisc is not supported on %v", OS)
|
||||
}
|
||||
if opts.Sandbox == sandboxNamespace ||
|
||||
(opts.Sandbox == sandboxSetuid && !(OS == "openbsd" || OS == "freebsd")) ||
|
||||
(opts.Sandbox == sandboxSetuid && !(OS == openbsd || OS == freebsd)) ||
|
||||
opts.Sandbox == sandboxAndroidUntrustedApp {
|
||||
return fmt.Errorf("Sandbox=%v is not supported on %v", opts.Sandbox, OS)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user