
This migrates uses of github.com/opencontainers/runc/libcontainer/user
to the new github.com/moby/sys/user module, which was extracted from
runc at commit [opencontainers/runc@a3a0ec48c4].
This is the initial release of the module, which is a straight copy, but
some changes may be made in the next release (such as fixing camel-casing
in some fields and functions (Uid -> UID).
[opencontainers/runc@a3a0ec48c4]: a3a0ec48c4
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
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
|
|
}
|