Check for invalid arguments

Caused crash when recvfrom was using null buffer
This commit is contained in:
Inviuz 2017-03-25 11:20:55 +01:00 committed by Ivan
parent 149c08ba78
commit 08c9a7c184
1 changed files with 6 additions and 0 deletions

View File

@ -444,6 +444,12 @@ namespace sys_net
memcpy(&_addr, addr.get_ptr(), sizeof(::sockaddr));
_addr.sa_family = addr->sa_family;
if (!sock || !buf || len == 0)
{
libnet.error("recvfrom(): invalid arguments buf= *0x%x, len=%d", buf, len);
return SYS_NET_EINVAL;
}
if (s < 0) {
libnet.error("recvfrom(): invalid socket %d", s);
return SYS_NET_EBADF;