1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00

Fix accept4 ignoring addrlen parameter as input.

This commit is contained in:
Jonas 'Sortie' Termansen 2014-01-15 23:22:19 +01:00
parent 6473d72621
commit 187cdf03dc

View file

@ -36,9 +36,10 @@ extern "C" int accept4(int fd, struct sockaddr* restrict addr,
// that type is designed to be size_t-sized anyway, the compiler should be
// able to optimize all this type safety away, but this function will work
// should the assumption sizeof(size_t) == sizeof(socklen_t) change.
size_t addrlen_size_t;
size_t addrlen_size_t = addrlen ? *addrlen : 0;
size_t* addrlen_size_t_ptr = addrlen ? &addrlen_size_t : NULL;
int retfd = sys_accept4(fd, addr, addrlen_size_t_ptr, flags);
if ( addrlen ) *addrlen = addrlen_size_t;
if ( addrlen )
*addrlen = addrlen_size_t;
return retfd;
}