mirror of
https://github.com/opencontainers/runc.git
synced 2025-10-25 00:20:47 +08:00
Go 1.17 introduce this new (and better) way to specify build tags. For more info, see https://golang.org/design/draft-gobuild. As a way to seamlessly switch from old to new build tags, gofmt (and gopls) from go 1.17 adds the new tags along with the old ones. Later, when go < 1.17 is no longer supported, the old build tags can be removed. Now, as I started to use latest gopls (v0.7.1), it adds these tags while I edit. Rather than to randomly add new build tags, I guess it is better to do it once for all files. Mind that previous commits removed some tags that were useless, so this one only touches packages that can at least be built on non-linux. Brought to you by go1.17 fmt ./... Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
44 lines
781 B
Go
44 lines
781 B
Go
//go:build gofuzz
|
|
// +build gofuzz
|
|
|
|
package user
|
|
|
|
import (
|
|
"io"
|
|
"strings"
|
|
)
|
|
|
|
func IsDivisbleBy(n int, divisibleby int) bool {
|
|
return (n % divisibleby) == 0
|
|
}
|
|
|
|
func FuzzUser(data []byte) int {
|
|
if len(data) == 0 {
|
|
return -1
|
|
}
|
|
if !IsDivisbleBy(len(data), 5) {
|
|
return -1
|
|
}
|
|
|
|
var divided [][]byte
|
|
|
|
chunkSize := len(data) / 5
|
|
|
|
for i := 0; i < len(data); i += chunkSize {
|
|
end := i + chunkSize
|
|
|
|
divided = append(divided, data[i:end])
|
|
}
|
|
|
|
_, _ = ParsePasswdFilter(strings.NewReader(string(divided[0])), nil)
|
|
|
|
var passwd, group io.Reader
|
|
|
|
group = strings.NewReader(string(divided[1]))
|
|
_, _ = GetAdditionalGroups([]string{string(divided[2])}, group)
|
|
|
|
passwd = strings.NewReader(string(divided[3]))
|
|
_, _ = GetExecUser(string(divided[4]), nil, passwd, group)
|
|
return 1
|
|
}
|