From pb@fasterix.frmug.org  Sun Dec 14 09:43:15 1997
Received: from frmug.org (frmug-gw.frmug.org [193.56.58.252])
          by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id JAA21870
          for <FreeBSD-gnats-submit@freebsd.org>; Sun, 14 Dec 1997 09:43:10 -0800 (PST)
          (envelope-from pb@fasterix.frmug.org)
Received: (from uucp@localhost)
	by frmug.org (8.8.8/frmug-2.1/nospam) with UUCP id SAA22891
	for FreeBSD-gnats-submit@freebsd.org; Sun, 14 Dec 1997 18:43:01 +0100 (CET)
	(envelope-from pb@fasterix.frmug.org)
Received: (from pb@localhost)
	by fasterix.frmug.org (8.8.8/8.8.5/pb-19970302) id SAA00682;
	Sun, 14 Dec 1997 18:34:20 +0100 (CET)
Message-Id: <199712141734.SAA00682@fasterix.frmug.org>
Date: Sun, 14 Dec 1997 18:34:20 +0100 (CET)
From: Pierre Beyssac <pb@fasterix.freenix.org>
Reply-To: pb@fasterix.freenix.org
To: FreeBSD-gnats-submit@freebsd.org
Subject: oaccept() not correctly returning peer address
X-Send-Pr-Version: 3.2

>Number:         5291
>Category:       kern
>Synopsis:       oaccept() not correctly returning peer address
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    msmith@freebsd.org
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Dec 14 09:50:01 PST 1997
>Closed-Date:    Sun Dec 14 18:29:29 PST 1997
>Last-Modified:  Sun Dec 14 18:31:55 PST 1997
>Originator:     Pierre Beyssac
>Release:        FreeBSD 3.0-CURRENT i386
>Organization:
individual
>Environment:

3.0-current kernel compiled with COMPAT_43. Linux emulator.

>Description:

oaccept() doesn't correctly return the peer sockaddr.
This is the same as the previous problem with recvfrom().

>How-To-Repeat:

Use any Linux program which does an accept() and displays the peer
address. I used "nc -l -vv -p 1200", then telnet localhost 1200.

>Fix:
	
--- uipc_syscalls.c.orig	Sun Dec 14 15:05:04 1997
+++ uipc_syscalls.c	Sun Dec 14 18:28:44 1997
@@ -242,15 +242,16 @@
 			goto gotnoname;
 		return 0;
 	}
 	if (uap->name) {
+		/* check sa_len before it is destroyed */
+		if (namelen > sa->sa_len)
+			namelen = sa->sa_len;
 #ifdef COMPAT_OLDSOCK
 		if (compat)
 			((struct osockaddr *)sa)->sa_family =
 			    sa->sa_family;
 #endif
-		if (namelen > sa->sa_len)
-			namelen = sa->sa_len;
 		error = copyout(sa, (caddr_t)uap->name, (u_int)namelen);
 		if (!error)
 gotnoname:
 			error = copyout((caddr_t)&namelen,
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: msmith 
State-Changed-When: Sun Dec 14 18:29:29 PST 1997 
State-Changed-Why:  
The supplied patch was applied in rev 1.34 of sys/kern/uipc_syscalls.c 


Responsible-Changed-From-To: freebsd-bugs->msmith@freebsd.org 
Responsible-Changed-By: msmith 
Responsible-Changed-When: Sun Dec 14 18:29:29 PST 1997 
Responsible-Changed-Why:  
Seems I'm convenient. 
>Unformatted:
