From: Scott Cantor Date: Thu, 3 May 2012 22:27:16 +0000 (+0000) Subject: Apply BSD fix to connect call X-Git-Tag: 2.5.0~115 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=shibboleth%2Fcpp-sp.git;a=commitdiff_plain;h=31cb6b80b1c9c37aa859f599af0c47a2a31cbeb5 Apply BSD fix to connect call --- diff --git a/shibsp/remoting/impl/TCPListener.cpp b/shibsp/remoting/impl/TCPListener.cpp index c498163..5f07611 100644 --- a/shibsp/remoting/impl/TCPListener.cpp +++ b/shibsp/remoting/impl/TCPListener.cpp @@ -232,7 +232,17 @@ bool TCPListener::connect(ShibSocket& s) const if(SOCKET_ERROR==::connect(s, (const struct sockaddr*)&m_sockaddr, sizeof(m_sockaddr))) return log_error("connect"); #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 (::connect(s, (const struct sockaddr*)&m_sockaddr, m_sockaddr.ss_len) < 0) +# else + if (::connect(s, (const struct sockaddr*)&m_sockaddr, m_sockaddr.sin_len) < 0) +# endif +# else if (::connect(s, (const struct sockaddr*)&m_sockaddr, sizeof(m_sockaddr)) < 0) +# endif return log_error("connect"); #endif return true;