Full_Name: Michael B Allen Version: 2.3.33 OS: Linux 2.6 URL: ftp://ftp.openldap.org/incoming/ Submission from: (NULL) (69.142.196.170)
ldap_search_ext with cldap:// will assert because it calls ldap_build_search_req which calls ber_write w/ a NULL ld->ld_options.ldo_peer.
The following patch defers encoding the address with ber_write until after the ldo_peer is initialized in request.c.
Note that cldap functionality is still not optimal. The transport hangs if there is no reply.
--- search.c-2007-05-30 2007-05-30 21:20:06.000000000 -0400 +++ search.c 2007-05-30 21:50:45.000000000 -0400 @@ -259,8 +259,9 @@ LDAP_NEXT_MSGID( ld, *idp ); #ifdef LDAP_CONNECTIONLESS if ( LDAP_IS_UDP(ld) ) { - err = ber_write( ber, ld->ld_options.ldo_peer, - sizeof(struct sockaddr), 0); + struct sockaddr sa; + memset(&sa, 0, sizeof sa); + err = ber_write( ber, &sa, sizeof(struct sockaddr), 0); } if ( LDAP_IS_UDP(ld) && ld->ld_options.ldo_version == LDAP_VERSION2) { char *dn = ld->ld_options.ldo_cldapdn; --- request.c-2007-05-30 2007-05-30 21:39:05.000000000 -0400 +++ request.c 2007-05-30 21:54:33.000000000 -0400 @@ -222,6 +222,19 @@
use_connection( ld, lc );
+#ifdef LDAP_CONNECTIONLESS + if ( LDAP_IS_UDP(ld) ) { + BerElement tmp = *ber; + ber_rewind( &tmp ); /* encode addr at start */ + rc = ber_write( &tmp, ld->ld_options.ldo_peer, + sizeof(struct sockaddr), 0); + if ( rc == -1 ) { + ld->ld_errno = LDAP_ENCODING_ERROR; + return( -1 ); + } + } +#endif + /* If we still have an incomplete write, try to finish it before * dealing with the new request. If we don't finish here, return * LDAP_BUSY and let the caller retry later. We only allow a single