Fix panic caused by invalid address for Bind in packet sockets.

PiperOrigin-RevId: 298476533
This commit is contained in:
Nayana Bidari
2020-03-02 16:31:52 -08:00
committed by gVisor bot
parent d80b6a6e49
commit 43abb24657
2 changed files with 17 additions and 0 deletions
+4
View File
@@ -712,6 +712,10 @@ func (s *SocketOperations) Connect(t *kernel.Task, sockaddr []byte, blocking boo
// Bind implements the linux syscall bind(2) for sockets backed by
// tcpip.Endpoint.
func (s *SocketOperations) Bind(t *kernel.Task, sockaddr []byte) *syserr.Error {
if len(sockaddr) < 2 {
return syserr.ErrInvalidArgument
}
family := usermem.ByteOrder.Uint16(sockaddr)
var addr tcpip.FullAddress