]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/netinet/in_pcb.c
xnu-1504.9.17.tar.gz
[apple/xnu.git] / bsd / netinet / in_pcb.c
index 10efe37f0f35a21a4e241e5df73cacf827ec86ba..696222176684638d87c4790722309558fd51713b 100644 (file)
@@ -776,7 +776,7 @@ in_pcbconnect(struct inpcb *inp, struct sockaddr *nam, struct proc *p)
            inp->inp_lport, 0, NULL);
        socket_lock(inp->inp_socket, 0);
        if (pcb != NULL) {
-               in_pcb_checkstate(pcb, WNT_RELEASE, 0);
+               in_pcb_checkstate(pcb, WNT_RELEASE, pcb == inp ? 1 : 0);
                return (EADDRINUSE);
        }
        if (inp->inp_laddr.s_addr == INADDR_ANY) {
@@ -1621,9 +1621,14 @@ inp_route_copyout(struct inpcb *inp, struct route *dst)
 
        lck_mtx_assert(inp->inpcb_mtx, LCK_MTX_ASSERT_OWNED);
 
-       /* Minor sanity check */
-       if (src->ro_rt != NULL && rt_key(src->ro_rt)->sa_family != AF_INET)
-               panic("%s: wrong or corrupted route: %p", __func__, src);
+       /*
+        * If the route in the PCB is not for IPv4, blow it away;
+        * this is possible in the case of IPv4-mapped address case.
+        */
+       if (src->ro_rt != NULL && rt_key(src->ro_rt)->sa_family != AF_INET) {
+               rtfree(src->ro_rt);
+               src->ro_rt = NULL;
+       }
 
        /* Copy everything (rt, dst, flags) from PCB */
        bcopy(src, dst, sizeof (*dst));