X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libraries%2Flibldap%2Furl.c;h=c5a4e0650c7f12181aaac0a97e7b315a5601533a;hb=8f4f94d4152185f2e445ec0929787095ff15f922;hp=7541e854152c83d07ad4bd50af95b11760b1b0fa;hpb=ca2145cccfda19c82e1f220f368d938405abe76c;p=openldap diff --git a/libraries/libldap/url.c b/libraries/libldap/url.c index 7541e85415..c5a4e0650c 100644 --- a/libraries/libldap/url.c +++ b/libraries/libldap/url.c @@ -24,7 +24,8 @@ #include "portable.h" #include -#include + +#include #include #include @@ -105,7 +106,7 @@ ldap_url_parse( LDAP_CONST char *url_in, LDAPURLDesc **ludpp ) const char *url_tmp; char *url; - Debug( LDAP_DEBUG_TRACE, "ldap_url_parse(%s)\n", url, 0, 0 ); + Debug( LDAP_DEBUG_TRACE, "ldap_url_parse(%s)\n", url_in, 0, 0 ); *ludpp = NULL; /* pessimistic */ @@ -116,15 +117,15 @@ ldap_url_parse( LDAP_CONST char *url_in, LDAPURLDesc **ludpp ) } /* make working copy of the remainder of the URL */ - if (( url = strdup( url_tmp )) == NULL ) { + if (( url = LDAP_STRDUP( url_tmp )) == NULL ) { return( LDAP_URL_ERR_MEM ); } /* allocate return struct */ - if (( ludp = (LDAPURLDesc *)calloc( 1, sizeof( LDAPURLDesc ))) + if (( ludp = (LDAPURLDesc *)LDAP_CALLOC( 1, sizeof( LDAPURLDesc ))) == NULLLDAPURLDESC ) { - free( url ); + LDAP_FREE( url ); return( LDAP_URL_ERR_MEM ); } @@ -212,7 +213,7 @@ ldap_url_parse( LDAP_CONST char *url_in, LDAPURLDesc **ludpp ) } } - if (( ludp->lud_attrs = (char **)calloc( nattrs + 1, + if (( ludp->lud_attrs = (char **)LDAP_CALLOC( nattrs + 1, sizeof( char * ))) == NULL ) { ldap_free_urldesc( ludp ); return( LDAP_URL_ERR_MEM ); @@ -238,12 +239,12 @@ ldap_free_urldesc( LDAPURLDesc *ludp ) { if ( ludp != NULLLDAPURLDESC ) { if ( ludp->lud_string != NULL ) { - free( ludp->lud_string ); + LDAP_FREE( ludp->lud_string ); } if ( ludp->lud_attrs != NULL ) { - free( ludp->lud_attrs ); + LDAP_FREE( ludp->lud_attrs ); } - free( ludp ); + LDAP_FREE( ludp ); } } @@ -255,9 +256,7 @@ ldap_url_search( LDAP *ld, LDAP_CONST char *url, int attrsonly ) int err; LDAPURLDesc *ludp; BerElement *ber; -#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS LDAPServer *srv = NULL; -#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */ if ( ldap_url_parse( url, &ludp ) != 0 ) { ld->ld_errno = LDAP_PARAM_ERROR; @@ -268,45 +267,35 @@ ldap_url_search( LDAP *ld, LDAP_CONST char *url, int attrsonly ) ludp->lud_filter, ludp->lud_attrs, attrsonly, NULL, NULL, -1, -1 ); - if ( ber == NULLBER ) { + if ( ber == NULL ) { return( -1 ); } err = 0; if ( ludp->lud_host != NULL || ludp->lud_port != 0 ) { -#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS - if (( srv = (LDAPServer *)calloc( 1, sizeof( LDAPServer ))) - == NULL || ( srv->lsrv_host = strdup( ludp->lud_host == + if (( srv = (LDAPServer *)LDAP_CALLOC( 1, sizeof( LDAPServer ))) + == NULL || ( srv->lsrv_host = LDAP_STRDUP( ludp->lud_host == NULL ? ld->ld_defhost : ludp->lud_host )) == NULL ) { if ( srv != NULL ) { - free( srv ); + LDAP_FREE( srv ); } ld->ld_errno = LDAP_NO_MEMORY; err = -1; } else { if ( ludp->lud_port == 0 ) { - srv->lsrv_port = openldap_ldap_global_options.ldo_defport; + srv->lsrv_port = ldap_int_global_options.ldo_defport; } else { srv->lsrv_port = ludp->lud_port; } } -#else /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */ - ld->ld_errno = LDAP_LOCAL_ERROR; - err = -1; -#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */ } if ( err != 0 ) { ber_free( ber, 1 ); } else { -#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS err = ldap_send_server_request( ld, ber, ld->ld_msgid, NULL, srv, NULL, 1 ); -#else /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */ - err = ldap_send_initial_request( ld, LDAP_REQ_SEARCH, - ludp->lud_dn, ber ); -#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */ } ldap_free_urldesc( ludp );