Subject: kern/3793: eliminate dtom() in sys/kern/uipc_usrreq.c
To: None <gnats-bugs@gnats.netbsd.org>
From: None <koji@math.human.nagoya-u.ac.jp>
List: netbsd-bugs
Date: 06/25/1997 20:09:46
>Number:         3793
>Category:       kern
>Synopsis:       eliminate dtom() in sys/kern/uipc_usrreq.c
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Wed Jun 25 04:20:02 1997
>Last-Modified:
>Originator:     Koji Imada - je4owb/2
>Organization:
Mathematics Group of Graduate School of Human
	Infomatics, Nagoya University, Japan.
>Release:        970622
>Environment:
	
System: NetBSD bimota 1.2E NetBSD 1.2E (BIMOTA) #: Wed Jun 11 02:13:27 JST 1997 koji@ducati:/mnt2/NetBSD/work/src-ufs-mod/sys/arch/i386/compile/BIMOTA i386


>Description:
	Eliminate dtom() in sys/kern/uipc_usrreq.c.
>How-To-Repeat:
	
>Fix:
	apply following patch.
Index: sys/kern/uipc_usrreq.c
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sys/kern/uipc_usrreq.c,v
retrieving revision 1.1.1.4
diff -u -r1.1.1.4 uipc_usrreq.c
--- uipc_usrreq.c	1997/05/23 21:58:18	1.1.1.4
+++ uipc_usrreq.c	1997/06/25 08:42:45
@@ -391,7 +391,11 @@
 	soisdisconnected(unp->unp_socket);
 	unp->unp_socket->so_pcb = 0;
 	if (unp->unp_addr)
+#if 1
+		free(unp->unp_addr, M_SONAME);
+#else
 		m_freem(dtom(unp->unp_addr));
+#endif
 	if (unp_rights) {
 		/*
 		 * Normally the receive buffer is flushed later,
@@ -451,8 +455,16 @@
 	vp = nd.ni_vp;
 	vp->v_socket = unp->unp_socket;
 	unp->unp_vnode = vp;
+#if 1
+	unp->unp_addr = (struct sockaddr_un *)malloc(nam->m_len+1, M_SONAME, M_NOWAIT);
+	if (unp->unp_addr != 0) {
+		m_copydata(nam, 0, nam->m_len, (caddr_t)unp->unp_addr);
+		*((caddr_t)unp->unp_addr + nam->m_len) = 0;
+	}
+#else
 	unp->unp_addr =
 	    mtod(m_copy(nam, 0, (int)M_COPYALL), struct sockaddr_un *);
+#endif
 	VOP_UNLOCK(vp);
 	return (0);
 }
@@ -502,9 +514,22 @@
 		}
 		unp2 = sotounpcb(so2);
 		unp3 = sotounpcb(so3);
+#if 1
+		if (unp2->unp_addr) {
+			unp3->unp_addr = (struct sockaddr_un *)malloc(unp2->unp_addr->sun_len+1,
+			    M_SONAME, M_NOWAIT);
+			if (unp3->unp_addr != 0) {
+				bcopy((caddr_t)unp2->unp_addr,
+				    (caddr_t)unp3->unp_addr,
+				    unp2->unp_addr->sun_len);
+				*((caddr_t)unp3->unp_addr + unp2->unp_addr->sun_len) = 0;
+			}
+		}
+#else
 		if (unp2->unp_addr)
 			unp3->unp_addr = mtod(m_copy(dtom(unp2->unp_addr), 0,
 			    (int)M_COPYALL), struct sockaddr_un *);
+#endif
 		so2 = so3;
 	}
 	error = unp_connect2(so, so2);
@@ -615,7 +640,11 @@
 		so->so_pcb = 0;
 		sofree(so);
 		if (unp->unp_addr)
+#if 1
+			free(unp->unp_addr, M_SONAME);
+#else
 			m_freem(dtom(unp->unp_addr));
+#endif
 		free(unp, M_PCB);
 	}
 }

>Audit-Trail:
>Unformatted: