Mercurial > dovecot > core-2.2
diff src/lib/network.c @ 3400:ddfa507bb74f HEAD
Don't return random data if net_getpeername() or net_getsockname() is used
for non-inet/inet6 socket.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 29 May 2005 03:26:19 +0300 |
parents | 690dcc51cdc1 |
children | d1ed3b3548db |
line wrap: on
line diff
--- a/src/lib/network.c Sat May 28 18:14:12 2005 +0300 +++ b/src/lib/network.c Sun May 29 03:26:19 2005 +0300 @@ -72,7 +72,10 @@ memcpy(&ip->ip, &so->sin6.sin6_addr, sizeof(ip->ip)); else #endif + if (ip->family == AF_INET) memcpy(&ip->ip, &so->sin.sin_addr, 4); + else + memset(&ip->ip, 0, sizeof(ip->ip)); } static inline void sin_set_port(union sockaddr_union *so, unsigned int port) @@ -91,7 +94,10 @@ if (so->sin.sin_family == AF_INET6) return ntohs(so->sin6.sin6_port); #endif - return ntohs(so->sin.sin_port); + if (so->sin.sin_family == AF_INET) + return ntohs(so->sin.sin_port); + + return 0; } static inline void close_save_errno(int fd)