* (fhandler_socket::getsockname): Fix length returned for unbound

AF_LOCAL sockets.
	(fhandler_socket::getpeername): Ditto.
	* net.cc (socketpair): Don't set sun_path and peer_sun_path to
	make sure getsockname and getpeername return the correct values
	for AF_LOCAL sockets.
This commit is contained in:
Corinna Vinschen 2009-08-14 06:58:44 +00:00
parent 95a1cc7024
commit c1999c4b0c
3 changed files with 11 additions and 6 deletions

View File

@ -1,3 +1,12 @@
2009-08-14 Corinna Vinschen <corinna@vinschen.de>
* (fhandler_socket::getsockname): Fix length returned for unbound
AF_LOCAL sockets.
(fhandler_socket::getpeername): Ditto.
* net.cc (socketpair): Don't set sun_path and peer_sun_path to
make sure getsockname and getpeername return the correct values
for AF_LOCAL sockets.
2009-08-13 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::accept): Use sizeof rather

View File

@ -1209,7 +1209,7 @@ fhandler_socket::getsockname (struct sockaddr *name, int *namelen)
if (get_sun_path ())
strncat (sun.sun_path, get_sun_path (), UNIX_PATH_LEN - 1);
memcpy (name, &sun, min (*namelen, (int) SUN_LEN (&sun) + 1));
*namelen = (int) SUN_LEN (&sun) + 1;
*namelen = (int) SUN_LEN (&sun) + (get_sun_path () ? 1 : 0);
res = 0;
}
else
@ -1283,7 +1283,7 @@ fhandler_socket::getpeername (struct sockaddr *name, int *namelen)
if (get_peer_sun_path ())
strncat (sun.sun_path, get_peer_sun_path (), UNIX_PATH_LEN - 1);
memcpy (name, &sun, min (*namelen, (int) SUN_LEN (&sun) + 1));
*namelen = (int) SUN_LEN (&sun) + 1;
*namelen = (int) SUN_LEN (&sun) + (get_peer_sun_path () ? 1 : 0);
}
else
{

View File

@ -2866,8 +2866,6 @@ socketpair (int family, int type, int protocol, int *sb)
if (sb0 >= 0 && fdsock (sb0, dev, insock))
{
((fhandler_socket *) sb0)->set_sun_path ("");
((fhandler_socket *) sb0)->set_peer_sun_path ("");
((fhandler_socket *) sb0)->set_addr_family (family);
((fhandler_socket *) sb0)->set_socket_type (type);
((fhandler_socket *) sb0)->connect_state (connected);
@ -2878,8 +2876,6 @@ socketpair (int family, int type, int protocol, int *sb)
if (sb1 >= 0 && fdsock (sb1, dev, outsock))
{
((fhandler_socket *) sb1)->set_sun_path ("");
((fhandler_socket *) sb1)->set_peer_sun_path ("");
((fhandler_socket *) sb1)->set_addr_family (family);
((fhandler_socket *) sb1)->set_socket_type (type);
((fhandler_socket *) sb1)->connect_state (connected);