[Date Prev][Date Next] [Chronological] [Thread] [Top]

(ITS#3487) setting LDAP_OPT_NETWORK_TIMEOUT twice causes SIGSEGV

Full_Name: Andrew Kozachenko
Version: 2.2.20
OS: Linux FC1
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (

Here is the client code wich causes SIGSEGV:

LDAP* ldap_connect(char *host, int port, char* dn, char* pw){
        LDAP *ld;
        int rc, version;
        struct timeval timeOut = {10,0};

        version = LDAP_VERSION3;
        ldap_set_option( NULL, LDAP_OPT_PROTOCOL_VERSION, &version);
        ldap_set_option( NULL, LDAP_OPT_NETWORK_TIMEOUT, &timeOut);

        if (( ld = ldap_init( host, port )) == NULL){
                fprintf ( stderr, "LDAP session initialization failed\n");
                return NULL;

        rc = ldap_simple_bind_s( ld, NULL, NULL );
        if (rc != LDAP_SUCCESS ){
                fprintf( stderr, "ldap_simple_bind_s: %s\n", ldap_err2string( rc
                ldap_unbind_s ( ld );
                return NULL;

        return ld;
        ld = ldap_connect("", 389, NULL, NULL);
        ld = ldap_connect("", 389, NULL, NULL);/*oops SIGSEGV*/

It only happens when ldap_set_option( NULL, LDAP_OPT_NETWORK_TIMEOUT, &timeOut)
called twice in separate function. It seems that openldap lib tries to use old
timeval set by previous call wich is not valid anymore.
Reproduced with libldap both 2.0 and 2.2.