[cpp-sp COMMIT] in /branches/REL_2: configure.ac shibsp/remoting/impl/TCPListener.cpp

noreply at shibboleth.net noreply at shibboleth.net
Thu May 3 22:36:17 BST 2012


Author: scantor
Date: Thu May  3 22:36:17 2012
New Revision: 3641

URL: http://svn.shibboleth.net/view/cpp-sp?rev=3641&view=rev
Log:
Fix BSD socket binds

Modified:
    branches/REL_2/configure.ac
    branches/REL_2/shibsp/remoting/impl/TCPListener.cpp

Modified: branches/REL_2/configure.ac
URL: http://svn.shibboleth.net/view/cpp-sp/branches/REL_2/configure.ac?rev=3641&r1=3640&r2=3641&view=diff
==============================================================================
--- branches/REL_2/configure.ac (original)
+++ branches/REL_2/configure.ac Thu May  3 22:36:17 2012
@@ -79,6 +79,8 @@
 AC_CHECK_HEADERS([sys/socket.h], [AC_DEFINE([SHIBSP_HAVE_SYS_SOCKET_H],[1],[Define to 1 if you have the <sys/socket> header file.])], [])
 AC_CHECK_FUNCS([strchr strdup strstr timegm gmtime_r strtok_r strcasecmp getpwnam getgrnam])
 AC_CHECK_TYPES([struct sockaddr_storage], [], [], [[#include <sys/socket.h>]])
+AC_CHECK_MEMBERS([struct sockaddr.sa_len], [], [], [[#include <sys/socket.h>]])
+
 
 # checks for pthreads
 ACX_PTHREAD([enable_threads="pthread"],[enable_threads="no"])

Modified: branches/REL_2/shibsp/remoting/impl/TCPListener.cpp
URL: http://svn.shibboleth.net/view/cpp-sp/branches/REL_2/shibsp/remoting/impl/TCPListener.cpp?rev=3641&r1=3640&r2=3641&view=diff
==============================================================================
--- branches/REL_2/shibsp/remoting/impl/TCPListener.cpp (original)
+++ branches/REL_2/shibsp/remoting/impl/TCPListener.cpp Thu May  3 22:36:17 2012
@@ -206,7 +206,17 @@
         return false;
     }
 #else
+    // Newer BSDs require the struct length be passed based on the socket address.
+    // Others have no field for that and take the whole struct size like Windows does.
+# ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
+#  ifdef HAVE_STRUCT_SOCKADDR_STORAGE
+    if (::bind(s, (const struct sockaddr*)&m_sockaddr, m_sockaddr.ss_len) < 0) {
+#  else
+    if (::bind(s, (const struct sockaddr*)&m_sockaddr, m_sockaddr.sin_len) < 0) {
+#  endif
+# else
     if (::bind(s, (const struct sockaddr*)&m_sockaddr, sizeof(m_sockaddr)) < 0) {
+# endif
         log_error("bind");
         close(s);
         return false;



More information about the commits mailing list