Commit 7995cb86 authored by Ian Gudger's avatar Ian Gudger Committed by Brad Fitzpatrick

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: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent fa897643
......@@ -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
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment