]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#10330 keep socket non-blocking during polling in ldap_int_tls_start
authorMichael Kourlas <michael.kourlas@solace.com>
Fri, 30 May 2025 21:57:23 +0000 (17:57 -0400)
committerQuanah Gibson-Mount <quanah@openldap.org>
Thu, 19 Jun 2025 13:49:40 +0000 (13:49 +0000)
During TLS negotiation, if a timeout is set, ldap_int_tls_start sets the
socket to non-blocking and calls ldap_int_poll in a loop if
ldap_int_tls_connect does not succeed the first time it is called.

However, ldap_int_poll sets the socket back to blocking and we currently
do not set it back to non-blocking. This means that a subsequent call to
ldap_int_tls_connect may hang and the configured timeout will not be
enforced. To fix this, we now set the socket back to non-blocking after
ldap_int_poll is called.

libraries/libldap/tls2.c

index 3a07aa0edd089346e2dec1370185c88dbab73941..1bda3fb2aad7737b0fd318e1f139e4b9253e2c81 100644 (file)
@@ -1227,6 +1227,9 @@ ldap_int_tls_start ( LDAP *ld, LDAPConn *conn, LDAPURLDesc *srv )
                                ld->ld_errno = LDAP_TIMEOUT;
                                break;
                        }
+                       /* ldap_int_poll switches the socket back to blocking, but we want
+                        * it non-blocking before calling ldap_int_tls_connect */
+                       ber_sockbuf_ctrl( sb, LBER_SB_OPT_SET_NONBLOCK, (void*)1 );
                }
                ret = ldap_int_tls_connect( ld, conn, host );
        }