Enforce Unix socket address length limit

PiperOrigin-RevId: 208720936
Change-Id: Ic943a88b6efeff49574306d4d4e1f113116ae32e
This commit is contained in:
Ian Gudger 2018-08-14 15:05:44 -07:00 committed by Shentubot
parent 6cf2278167
commit e97717e29a
1 changed files with 3 additions and 0 deletions

View File

@ -150,6 +150,9 @@ func GetAddress(sfamily int, addr []byte) (tcpip.FullAddress, *syserr.Error) {
switch family {
case linux.AF_UNIX:
path := addr[2:]
if len(path) > linux.UnixPathMax {
return tcpip.FullAddress{}, syserr.ErrInvalidArgument
}
// Drop the terminating NUL (if one exists) and everything after it.
// Skip the first byte, which is NUL for abstract paths.
if len(path) > 1 {