[dovecot-cvs] dovecot/src/lib fdpass.c,1.16,1.17

cras at procontrol.fi cras at procontrol.fi
Tue Apr 8 17:12:50 EEST 2003


Update of /home/cvs/dovecot/src/lib
In directory danu:/tmp/cvs-serv31693/lib

Modified Files:
	fdpass.c 
Log Message:
Tru64 fixes. More comments.



Index: fdpass.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/fdpass.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- fdpass.c	4 Apr 2003 12:09:27 -0000	1.16
+++ fdpass.c	8 Apr 2003 13:12:47 -0000	1.17
@@ -1,7 +1,15 @@
 /*
- fdpass.c - FD passing
+ fdpass.c - File descriptor passing between processes via UNIX sockets
 
-    Copyright (c) 2002 Timo Sirainen
+ This isn't fully portable, but pretty much all UNIXes nowadays should
+ support this. If you're having runtime problems, check the end of fd_read()
+ and play with the if condition.
+
+ If this file doesn't compile at all, you should check if this is supported
+ in your system at all. It may require some extra #define to enable it.
+ If not, you're pretty much out of luck. Cygwin didn't last I checked.
+
+    Copyright (c) 2002-2003 Timo Sirainen
 
     Permission is hereby granted, free of charge, to any person obtaining
     a copy of this software and associated documentation files (the
@@ -107,9 +115,18 @@
 		return ret;
 	}
 
-	/* at least one byte transferred - we should have the fd now */
+	/* at least one byte transferred - we should have the fd now.
+	   do extra checks to make sure it really is an fd that is being
+	   transferred to avoid potential DoS conditions. some systems don't
+	   set all these values correctly however:
+
+	   Linux 2.0.x - cmsg_len, cmsg_level, cmsg_type are not set
+	   Tru64 - msg_controllen isn't set */
 	cmsg = CMSG_FIRSTHDR(&msg);
-	if (msg.msg_controllen < CMSG_SPACE(sizeof(int)) ||
+	if (
+#ifndef __osf__
+	    msg.msg_controllen < CMSG_SPACE(sizeof(int)) ||
+#endif
 	    cmsg == NULL || cmsg->cmsg_len < CMSG_LEN(sizeof(int)) ||
 	    cmsg->cmsg_level != SOL_SOCKET || cmsg->cmsg_type != SCM_RIGHTS)
 		*fd = -1;




More information about the dovecot-cvs mailing list