From owner-freebsd-current Sat Dec 13 09:20:26 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id JAA03615 for current-outgoing; Sat, 13 Dec 1997 09:20:26 -0800 (PST) (envelope-from owner-freebsd-current) 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 JAA03595 for ; Sat, 13 Dec 1997 09:20:09 -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 SAA27958 for freebsd-current@freebsd.org; Sat, 13 Dec 1997 18:20:06 +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 SAA00647; Sat, 13 Dec 1997 18:18:09 +0100 (CET) Message-ID: <19971213181809.AU40295@@> Date: Sat, 13 Dec 1997 18:18:09 +0100 From: pb@fasterix.freenix.org (Pierre Beyssac) To: freebsd-current@freebsd.org Subject: small patch to fix MSG_COMPAT in recvfrom() X-Mailer: Mutt 0.59.1e Mime-Version: 1.0 Sender: owner-freebsd-current@freebsd.org X-Loop: FreeBSD.org Precedence: bulk Hello, Could someone check this and possibly commit it to -current if it is correct? It seems to fix a bug with orecvfrom() or recvfrom() called with the MSG_COMPAT flag on kernels compiled with the COMPAT_43 option. The symptom is that the fromaddr is not correctly returned. This affects the Linux emulator. I also have several other patches regarding the use of sockets by the Linux emulator, notably getsockopt(), raw sockets, and the IP_HDRINCL option which Linux handles differently from BSD in a subtle way. It allows me to run Linux ping, traceroute, and other small network "utilities" compiled on Linux such as teardrop. Should I send these patches to the list or to the Linux emulator maintainer? --- /sys/kern/uipc_syscalls.c.orig Tue Dec 9 01:42:58 1997 +++ /sys/kern/uipc_syscalls.c Sat Dec 13 18:05:46 1997 @@ -699,17 +699,18 @@ len = mp->msg_namelen; if (len <= 0 || fromsa == 0) len = 0; else { +#ifndef MIN +#define MIN(a,b) ((a)>(b)?(b):(a)) +#endif + /* save sa_len before it is destroyed by MSG_COMPAT */ + len = MIN(len, fromsa->sa_len); #ifdef COMPAT_OLDSOCK if (mp->msg_flags & MSG_COMPAT) ((struct osockaddr *)fromsa)->sa_family = fromsa->sa_family; #endif -#ifndef MIN -#define MIN(a,b) ((a)>(b)?(b):(a)) -#endif - len = MIN(len, fromsa->sa_len); error = copyout(fromsa, (caddr_t)mp->msg_name, (unsigned)len); if (error) goto out; -- Pierre Beyssac pb@fasterix.frmug.org pb@fasterix.freenix.org {Free,Net,Open}BSD, Linux : il y a moins bien, mais c'est plus cher Free domains: http://www.eu.org/ or mail dns-manager@EU.org