* sockets.c (lwip_accept): check addr isn't NULL. If it's valid, do an

assertion check that addrlen isn't NULL.
This commit is contained in:
jifl 2008-09-30 14:51:27 +00:00
parent c231e95cce
commit 0d7dccba5e
2 changed files with 18 additions and 8 deletions

View File

@ -47,6 +47,10 @@ HISTORY
++ Bugfixes: ++ Bugfixes:
2008-09-30 Jonathan Larmour
* sockets.c (lwip_accept): check addr isn't NULL. If it's valid, do an
assertion check that addrlen isn't NULL.
2008-09-30 Jonathan Larmour 2008-09-30 Jonathan Larmour
* tcp.c: Fix bug #24227, wrong error message in tcp_bind. * tcp.c: Fix bug #24227, wrong error message in tcp_bind.

View File

@ -273,16 +273,22 @@ lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
return -1; return -1;
} }
memset(&sin, 0, sizeof(sin)); /* Note that POSIX only requires us to check addr is non-NULL. addrlen must
sin.sin_len = sizeof(sin); * not be NULL if addr is valid.
sin.sin_family = AF_INET; */
sin.sin_port = htons(port); if (NULL != addr) {
sin.sin_addr.s_addr = naddr.addr; LWIP_ASSERT("addr valid but addrlen NULL", addrlen != NULL);
memset(&sin, 0, sizeof(sin));
sin.sin_len = sizeof(sin);
sin.sin_family = AF_INET;
sin.sin_port = htons(port);
sin.sin_addr.s_addr = naddr.addr;
if (*addrlen > sizeof(sin)) if (*addrlen > sizeof(sin))
*addrlen = sizeof(sin); *addrlen = sizeof(sin);
SMEMCPY(addr, &sin, *addrlen); SMEMCPY(addr, &sin, *addrlen);
}
newsock = alloc_socket(newconn); newsock = alloc_socket(newconn);
if (newsock == -1) { if (newsock == -1) {