From 3581cc66bbd6129e945fd3ba12dcebb6e95842c4 Mon Sep 17 00:00:00 2001 From: "Christian S.J. Peron" Date: Mon, 10 May 2004 15:07:23 +0000 Subject: [PATCH] Zero the un-used portions of the struct sockaddr data before sending it back to userspace, so it does not break bind(2) on raw sockets in jails. Currently some processes, like traceroute(8) construct a routing request to determine its source address based on the destination. This sockaddr data is fed directly to bind(2). When bind calls ifa_ifwithaddr(9) to make sure the address exists on the interface, the comparison will fail causing bind(2) to return EADDRNOTAVAIL if the data wasnt zero'ed before initialization. Approved by: bmilekic (mentor) --- sys/net/rtsock.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index 002432b1692..d5e1abe6dd6 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -404,6 +404,7 @@ route_output(struct mbuf *m, struct socket *so) info.rti_info[RTAX_IFP] = ifaddr_byindex(ifp->if_index)->ifa_addr; if (jailed(so->so_cred)) { + memset(&jail, 0, sizeof(jail)); jail.sin_family = PF_INET; jail.sin_len = sizeof(jail); jail.sin_addr.s_addr =