Debian Codegraph @

debian/patches/getaddrinfo-is-threadsafe

raw
1 Author: Steve Langasek <[email protected]>
2
3 OpenLDAP upstream conservatively assumes that certain resolver functions
4 (getaddrinfo, getnameinfo, res_query, dn_expand) are not re-entrant; but we
5 know that the glibc implementations of these functions are thread-safe, so
6 we should bypass the use of this mutex. This fixes a locking problem when
7 an application uses libldap and libnss-ldap is also used for hosts
8 resolution.
9
10 Closes Debian bug #340601.
11
12 Not suitable for forwarding upstream; might be made suitable by adding a
13 configure-time check for glibc and disabling the mutex only on known
14 thread-safe implementations.
15
16 Index: openldap/libraries/libldap/os-ip.c
17 ===================================================================
18 --- openldap.orig/libraries/libldap/os-ip.c 2022-05-20 17:36:12.989246703 -0400
19 +++ openldap/libraries/libldap/os-ip.c 2022-05-20 17:36:12.989246703 -0400
20 @@ -645,13 +645,7 @@
21 hints.ai_socktype = socktype;
22 snprintf(serv, sizeof serv, "%d", port );
23
24 - /* most getaddrinfo(3) use non-threadsafe resolver libraries */
25 - LDAP_MUTEX_LOCK(&ldap_int_resolv_mutex);
26 -
27 err = getaddrinfo( host, serv, &hints, &res );
28 -
29 - LDAP_MUTEX_UNLOCK(&ldap_int_resolv_mutex);
30 -
31 if ( err != 0 ) {
32 Debug1(LDAP_DEBUG_TRACE,
33 "ldap_connect_to_host: getaddrinfo failed: %s\n",
34 Index: openldap/libraries/libldap/util-int.c
35 ===================================================================
36 --- openldap.orig/libraries/libldap/util-int.c 2022-05-20 17:36:12.989246703 -0400
37 +++ openldap/libraries/libldap/util-int.c 2022-05-20 17:36:12.989246703 -0400
38 @@ -559,9 +559,7 @@
39 int rc;
40 #if defined( HAVE_GETNAMEINFO )
41
42 - LDAP_MUTEX_LOCK( &ldap_int_resolv_mutex );
43 rc = getnameinfo( sa, len, name, namelen, NULL, 0, 0 );
44 - LDAP_MUTEX_UNLOCK( &ldap_int_resolv_mutex );
45 if ( rc ) *err = (char *)AC_GAI_STRERROR( rc );
46 return rc;
47