Fix bug # 138612 - should use gethostbyname_r() on Linux.

This commit is contained in:
mcs%netscape.com 2002-04-22 16:57:50 +00:00
Родитель a4591dfe82
Коммит b7bb14990f
2 изменённых файлов: 24 добавлений и 7 удалений

Просмотреть файл

@ -282,12 +282,19 @@ int strncasecmp(const char *, const char *, size_t);
#define STRTOK( s1, s2, l ) strtok_r( s1, s2, l )
#define HAVE_STRTOK_R
#else /* UNIX */
#if defined(sgi) || defined(HPUX9) || defined(LINUX1_2) || defined(SCOOS) || \
#if (defined(AIX) && defined(_THREAD_SAFE)) || defined(OSF1)
#define NSLDAPI_NETDB_BUF_SIZE sizeof(struct protoent_data)
#else
#define NSLDAPI_NETDB_BUF_SIZE 1024
#endif
#if defined(sgi) || defined(HPUX9) || defined(SCOOS) || \
defined(UNIXWARE) || defined(SUNOS4) || defined(SNI) || defined(BSDI) || \
defined(NCR) || defined(OSF1) || defined(NEC) || defined(VMS) || \
( defined(HPUX10) && !defined(_REENTRANT)) || defined(HPUX11) || \
defined(UnixWare) || defined(LINUX) || defined(NETBSD) || \
defined(UnixWare) || defined(NETBSD) || \
defined(FREEBSD) || defined(OPENBSD) || \
(defined(LINUX) && __GLIBC__ < 2) || \
(defined(AIX) && !defined(USE_REENTRANT_LIBC))
#define GETHOSTBYNAME( n, r, b, l, e ) gethostbyname( n )
#elif defined(AIX)
@ -296,16 +303,20 @@ int strncasecmp(const char *, const char *, size_t);
Replaced with following to lines, stolen from the #else below
#define GETHOSTBYNAME_BUF_T struct hostent_data
*/
typedef char GETHOSTBYNAME_buf_t [BUFSIZ /* XXX might be too small */];
typedef char GETHOSTBYNAME_buf_t [NSLDAPI_NETDB_BUF_SIZE];
#define GETHOSTBYNAME_BUF_T GETHOSTBYNAME_buf_t
#define GETHOSTBYNAME( n, r, b, l, e ) \
(memset (&b, 0, l), gethostbyname_r (n, r, &b) ? NULL : r)
#elif defined(HPUX10)
#define GETHOSTBYNAME_BUF_T struct hostent_data
#define GETHOSTBYNAME( n, r, b, l, e ) nsldapi_compat_gethostbyname_r( n, r, (char *)&b, l, e )
#elif defined(LINUX)
typedef char GETHOSTBYNAME_buf_t [NSLDAPI_NETDB_BUF_SIZE];
#define GETHOSTBYNAME_BUF_T GETHOSTBYNAME_buf_t
#define GETHOSTBYNAME( n, r, b, l, rp, e ) gethostbyname_r( n, r, b, l, rp, e )
#define GETHOSTBYNAME_R_RETURNS_INT
#else
#include <stdio.h> /* BUFSIZ */
typedef char GETHOSTBYNAME_buf_t [BUFSIZ /* XXX might be too small */];
typedef char GETHOSTBYNAME_buf_t [NSLDAPI_NETDB_BUF_SIZE];
#define GETHOSTBYNAME_BUF_T GETHOSTBYNAME_buf_t
#define GETHOSTBYNAME( n, r, b, l, e ) gethostbyname_r( n, r, b, l, e )
#endif

Просмотреть файл

@ -567,8 +567,14 @@ nsldapi_try_each_host( LDAP *ld, const char *hostlist,
if (( address = inet_addr( host )) == -1 ) {
if ( ld->ld_dns_gethostbyname_fn == NULL ) {
if (( hp = GETHOSTBYNAME( host, &hent, hbuf,
sizeof(hbuf), &err )) != NULL ) {
#ifdef GETHOSTBYNAME_R_RETURNS_INT
(void)GETHOSTBYNAME( host, &hent, hbuf,
sizeof(hbuf), &hp, &err );
#else
hp = GETHOSTBYNAME( host, &hent, hbuf,
sizeof(hbuf), &err );
#endif
if ( hp != NULL ) {
addrlist = hp->h_addr_list;
}
} else {