From: Steve Langasek Date: Tue, 17 Nov 2020 01:23:45 +0000 (+0000) Subject: getaddrinfo-is-threadsafe X-Git-Tag: archive/raspbian/2.4.47+dfsg-3+rpi1+deb10u4^2~24 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=53fd3adadc092167bd404b649a51433ee6fc8996;p=openldap.git getaddrinfo-is-threadsafe OpenLDAP upstream conservatively assumes that certain resolver functions (getaddrinfo, getnameinfo, res_query, dn_expand) are not re-entrant; but we know that the glibc implementations of these functions are thread-safe, so we should bypass the use of this mutex. This fixes a locking problem when an application uses libldap and libnss-ldap is also used for hosts resolution. Closes Debian bug #340601. Not suitable for forwarding upstream; might be made suitable by adding a configure-time check for glibc and disabling the mutex only on known thread-safe implementations. Gbp-Pq: Name getaddrinfo-is-threadsafe --- diff --git a/libraries/libldap/os-ip.c b/libraries/libldap/os-ip.c index 623dfadb..34557726 100644 --- a/libraries/libldap/os-ip.c +++ b/libraries/libldap/os-ip.c @@ -602,13 +602,7 @@ ldap_connect_to_host(LDAP *ld, Sockbuf *sb, hints.ai_socktype = socktype; snprintf(serv, sizeof serv, "%d", port ); - /* most getaddrinfo(3) use non-threadsafe resolver libraries */ - LDAP_MUTEX_LOCK(&ldap_int_resolv_mutex); - err = getaddrinfo( host, serv, &hints, &res ); - - LDAP_MUTEX_UNLOCK(&ldap_int_resolv_mutex); - if ( err != 0 ) { osip_debug(ld, "ldap_connect_to_host: getaddrinfo failed: %s\n", AC_GAI_STRERROR(err), 0, 0); diff --git a/libraries/libldap/util-int.c b/libraries/libldap/util-int.c index e65db0c2..319c4503 100644 --- a/libraries/libldap/util-int.c +++ b/libraries/libldap/util-int.c @@ -534,9 +534,7 @@ int ldap_pvt_get_hname( int rc; #if defined( HAVE_GETNAMEINFO ) - LDAP_MUTEX_LOCK( &ldap_int_resolv_mutex ); rc = getnameinfo( sa, len, name, namelen, NULL, 0, 0 ); - LDAP_MUTEX_UNLOCK( &ldap_int_resolv_mutex ); if ( rc ) *err = (char *)AC_GAI_STRERROR( rc ); return rc;