Merge pull request #305 from teto/getdomain_fix

Fixes a smashing stack problem as described in https://bugzilla.kernel.org/show_bug.cgi?id=104601
This commit is contained in:
Bruce A. Mah 2015-10-07 12:59:01 -07:00
commit 156a5eb163

View File

@ -457,10 +457,11 @@ setnonblocking(int fd, int nonblocking)
int
getsockdomain(int sock)
{
struct sockaddr sa;
struct sockaddr_storage sa;
socklen_t len = sizeof(sa);
if (getsockname(sock, &sa, &len) < 0)
return -1;
return sa.sa_family;
if (getsockname(sock, (struct sockaddr *)&sa, &len) < 0) {
return -1;
}
return ((struct sockaddr *) &sa)->sa_family;
}