Commit dfe83d41 authored by Mikio Hara's avatar Mikio Hara

internal/socket: don't crash with corrupted control messages

Change-Id: I5c484662add4261f504607758521718f4c760375
Reviewed-on: https://go-review.googlesource.com/45294
TryBot-Result: Gobot Gobot <gobot@golang.org>
Run-TryBot: Matt Layher <mdlayher@gmail.com>
Reviewed-by: 's avatarMatt Layher <mdlayher@gmail.com>
Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 9c9a3f3e
......@@ -175,6 +175,9 @@ func (m ControlMessage) Parse() ([]ControlMessage, error) {
for len(m) >= controlHeaderLen() {
h := (*cmsghdr)(unsafe.Pointer(&m[0]))
l := h.len()
if l <= 0 {
return nil, errors.New("invalid header length")
}
if uint64(l) < uint64(controlHeaderLen()) {
return nil, errors.New("invalid message length")
}
......
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