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() Message-ID: <19971213181809.AU40295@@>
index | next in thread | raw e-mail
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
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19971213181809.AU40295>
