mirror of https://github.com/golang/go.git
syscall: validate ParseUnixCredentials inputs
Don't panic, crash, or return references to uninitialized memory when ParseUnixCredentials is passed invalid input. Fixes #16475 Change-Id: I140d41612e8cd8caaa94be829a415159659c217b Reviewed-on: https://go-review.googlesource.com/25154 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
fa897643a1
commit
7995cb86e5
|
|
@ -31,6 +31,9 @@ func ParseUnixCredentials(m *SocketControlMessage) (*Ucred, error) {
|
|||
if m.Header.Type != SCM_CREDENTIALS {
|
||||
return nil, EINVAL
|
||||
}
|
||||
if uintptr(len(m.Data)) < unsafe.Sizeof(Ucred{}) {
|
||||
return nil, EINVAL
|
||||
}
|
||||
ucred := *(*Ucred)(unsafe.Pointer(&m.Data[0]))
|
||||
return &ucred, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue