Fix HP-UX crash: Replace socklen_t with ber_socklen_t from configure. ITS#4629.

This commit is contained in:
Hallvard Furuseth 2007-06-09 23:35:20 +00:00
parent 18a1d2e9af
commit 3750520f6f
6 changed files with 47 additions and 18 deletions

View File

@ -2133,14 +2133,43 @@ AC_CHECK_TYPE(size_t, unsigned)
AC_CHECK_TYPES([long long])
AC_CHECK_TYPES([ptrdiff_t])
AC_CHECK_TYPE([socklen_t],,
[AC_DEFINE_UNQUOTED([socklen_t], [int],
[Define to `int' if <sys/socket.h> does not define.])],
[$ac_includes_default
AC_CHECK_TYPE([socklen_t],,, [$ac_includes_default
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif])
dnl socklen_t-like type in accept(), default socklen_t or int:
dnl - The OS might define socklen_t without using it. POSIX moved from
dnl int to size_t to socklen_t, hoping to stay at a 32-bit type, and
dnl HP-UX now has selectors for what to use.
dnl - On Solaris 2.8 the prototype has void *len, but the default is OK.
AC_MSG_CHECKING([the type of arg 3 to accept()])
AC_CACHE_VAL(ol_cv_type_ber_socklen_t, [
set socklen_t int unsigned "unsigned long" long size_t
test "$ac_cv_type_socklen_t" = yes || shift
ol_cv_type_ber_socklen_t=$1 guessing="guessing "
for lentype in "$@" ; do for addrtype in "struct sockaddr" void ; do
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$ac_includes_default
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
])
extern int accept(int s, $addrtype *ap, $lentype *lp);
], [
accept(0, (struct sockaddr *) 0, ($lentype *) 0);
])], [ol_cv_type_ber_socklen_t=$lentype guessing= ; break 2])
done ; done])
AC_MSG_RESULT([$guessing$ol_cv_type_ber_socklen_t *])
AC_DEFINE_UNQUOTED(ber_socklen_t, $ol_cv_type_ber_socklen_t,
[Define to the type of arg 3 for `accept'.])
dnl Modules should use ber_socklen_t, not socklen_t. Define socklen_t
dnl for the time being anyway, for backwards compatibility.
if test "$ac_cv_type_socklen_t" != yes; then
AC_DEFINE_UNQUOTED([socklen_t], [$ol_cv_type_ber_socklen_t],
[Define like ber_socklen_t if <sys/socket.h> does not define.])
fi
AC_TYPE_SIGNAL

View File

@ -905,7 +905,7 @@ static ber_slen_t
sb_dgram_read( Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t len )
{
ber_slen_t rc;
socklen_t addrlen;
ber_socklen_t addrlen;
struct sockaddr *src;
assert( sbiod != NULL );

View File

@ -174,7 +174,7 @@ ldap_pvt_is_socket_ready(LDAP *ld, int s)
#if defined( notyet ) /* && defined( SO_ERROR ) */
{
int so_errno;
socklen_t dummy = sizeof(so_errno);
ber_socklen_t dummy = sizeof(so_errno);
if ( getsockopt( s, SOL_SOCKET, SO_ERROR, &so_errno, &dummy )
== AC_SOCKET_ERROR )
{
@ -196,7 +196,7 @@ ldap_pvt_is_socket_ready(LDAP *ld, int s)
struct sockaddr_in sin;
#endif
char ch;
socklen_t dummy = sizeof(sin);
ber_socklen_t dummy = sizeof(sin);
if ( getpeername( s, (struct sockaddr *) &sin, &dummy )
== AC_SOCKET_ERROR )
{
@ -350,7 +350,7 @@ ldap_int_poll(
static int
ldap_pvt_connect(LDAP *ld, ber_socket_t s,
struct sockaddr *sin, socklen_t addrlen,
struct sockaddr *sin, ber_socklen_t addrlen,
int async)
{
int rc, err;
@ -621,7 +621,7 @@ ldap_connect_to_host(LDAP *ld, Sockbuf *sb,
char *
ldap_host_connected_to( Sockbuf *sb, const char *host )
{
socklen_t len;
ber_socklen_t len;
#ifdef LDAP_PF_INET6
struct sockaddr_storage sabuf;
#else

View File

@ -120,7 +120,7 @@ ldap_pvt_is_socket_ready(LDAP *ld, int s)
#if defined( notyet ) /* && defined( SO_ERROR ) */
{
int so_errno;
socklen_t dummy = sizeof(so_errno);
ber_socklen_t dummy = sizeof(so_errno);
if ( getsockopt( s, SOL_SOCKET, SO_ERROR, &so_errno, &dummy )
== AC_SOCKET_ERROR )
{
@ -138,7 +138,7 @@ ldap_pvt_is_socket_ready(LDAP *ld, int s)
/* error slippery */
struct sockaddr_un sa;
char ch;
socklen_t dummy = sizeof(sa);
ber_socklen_t dummy = sizeof(sa);
if ( getpeername( s, (struct sockaddr *) &sa, &dummy )
== AC_SOCKET_ERROR )
{
@ -189,7 +189,7 @@ ldap_pvt_connect(LDAP *ld, ber_socket_t s, struct sockaddr_un *sa, int async)
sendcred:
{
int fds[2];
socklen_t salen = sizeof(*sa);
ber_socklen_t salen = sizeof(*sa);
if (pipe(fds) == 0) {
/* Abandon, noop, has no reply */
struct iovec iov;

View File

@ -62,7 +62,7 @@ int lutil_getpeereid( int s, uid_t *euid, gid_t *egid
#elif defined( SO_PEERCRED )
struct ucred peercred;
socklen_t peercredlen = sizeof peercred;
ber_socklen_t peercredlen = sizeof peercred;
if(( getsockopt( s, SOL_SOCKET, SO_PEERCRED,
(void *)&peercred, &peercredlen ) == 0 )
@ -75,7 +75,7 @@ int lutil_getpeereid( int s, uid_t *euid, gid_t *egid
#elif defined( LOCAL_PEERCRED )
struct xucred peercred;
socklen_t peercredlen = sizeof peercred;
ber_socklen_t peercredlen = sizeof peercred;
if(( getsockopt( s, LOCAL_PEERCRED, 1,
(void *)&peercred, &peercredlen ) == 0 )
@ -104,7 +104,7 @@ int lutil_getpeereid( int s, uid_t *euid, gid_t *egid
# endif /* HAVE_STRUCT_MSGHDR_MSG_CONTROL */
struct stat st;
struct sockaddr_un lname, rname;
socklen_t llen, rlen;
ber_socklen_t llen, rlen;
rlen = sizeof(rname);
llen = sizeof(lname);
@ -166,7 +166,7 @@ int lutil_getpeereid( int s, uid_t *euid, gid_t *egid
}
#elif defined(SOCKCREDSIZE)
struct msghdr msg;
socklen_t crmsgsize;
ber_socklen_t crmsgsize;
void *crmsg;
struct cmsghdr *cmp;
struct sockcred *sc;

View File

@ -1571,7 +1571,7 @@ slap_listener(
Sockaddr from;
ber_socket_t s;
socklen_t len = sizeof(from);
ber_socklen_t len = sizeof(from);
Connection *c;
slap_ssf_t ssf = 0;
struct berval authid = BER_BVNULL;