From 99f5983fb6e185fd1f135cb99776da6e581f71e1 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Wed, 5 Jun 2002 15:46:26 +0000 Subject: [PATCH] Consistently don't check for NULL session handle and other pointers. Application is responsible for providing valid session pointers. --- libraries/libldap/controls.c | 5 ++--- libraries/libldap/dnssrv.c | 7 +++---- libraries/libldap/error.c | 9 --------- libraries/libldap/extended.c | 10 ---------- libraries/libldap/getdn.c | 7 ++----- libraries/libldap/getentry.c | 4 +--- libraries/libldap/references.c | 12 +----------- libraries/libldap/result.c | 9 --------- libraries/libldap/sasl.c | 9 --------- libraries/libldap/sort.c | 6 ++---- libraries/libldap/sortctrl.c | 6 +++--- libraries/libldap/url.c | 12 ++++++------ libraries/libldap/vlvctrl.c | 14 +++++--------- 13 files changed, 25 insertions(+), 85 deletions(-) diff --git a/libraries/libldap/controls.c b/libraries/libldap/controls.c index 9925357b0c..76c2799236 100644 --- a/libraries/libldap/controls.c +++ b/libraries/libldap/controls.c @@ -413,9 +413,8 @@ ldap_create_control( LDAPControl *ctrl; struct berval *bvalp; - if ( requestOID == NULL || ctrlp == NULL ) { - return LDAP_PARAM_ERROR; - } + assert( requestOID != NULL ); + assert( ctrlp != NULL ); ctrl = (LDAPControl *) LDAP_MALLOC( sizeof(LDAPControl) ); if ( ctrl == NULL ) { diff --git a/libraries/libldap/dnssrv.c b/libraries/libldap/dnssrv.c index 55184676df..1a763c9b6e 100644 --- a/libraries/libldap/dnssrv.c +++ b/libraries/libldap/dnssrv.c @@ -200,11 +200,10 @@ int ldap_domain2hostlist( int rc, len, cur = 0; unsigned char reply[1024]; - if( domain == NULL || *domain == '\0' ) { - return LDAP_PARAM_ERROR; - } + assert( domain != NULL ); + assert( list != NULL ); - if( list == NULL ) { + if( *domain == '\0' ) { return LDAP_PARAM_ERROR; } diff --git a/libraries/libldap/error.c b/libraries/libldap/error.c index 8fc685b25f..3569887747 100644 --- a/libraries/libldap/error.c +++ b/libraries/libldap/error.c @@ -172,11 +172,6 @@ ldap_perror( LDAP *ld, LDAP_CONST char *str ) assert( LDAP_VALID( ld ) ); assert( str ); - if ( ld == NULL ) { - fprintf( stderr, "ldap_perror: invalid session handle\n" ); - return; - } - e = ldap_int_error( ld->ld_errno ); fprintf( stderr, "%s: %s (%d)\n", @@ -257,10 +252,6 @@ ldap_parse_result( assert( LDAP_VALID( ld ) ); assert( r != NULL ); - if ( ld == NULL || r == NULL ) { - return LDAP_PARAM_ERROR; - } - if(errcodep != NULL) *errcodep = LDAP_SUCCESS; if(matcheddnp != NULL) *matcheddnp = NULL; if(errmsgp != NULL) *errmsgp = NULL; diff --git a/libraries/libldap/extended.c b/libraries/libldap/extended.c index 58bffe8620..74e31281ca 100644 --- a/libraries/libldap/extended.c +++ b/libraries/libldap/extended.c @@ -60,11 +60,6 @@ ldap_extended_operation( return( ld->ld_errno ); } - if( reqoid == NULL || *reqoid == '\0' || msgidp == NULL ) { - ld->ld_errno = LDAP_PARAM_ERROR; - return( ld->ld_errno ); - } - /* create a message to send */ if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) { ld->ld_errno = LDAP_NO_MEMORY; @@ -132,11 +127,6 @@ ldap_extended_operation_s( assert( reqoid != NULL || *reqoid == '\0' ); assert( retoidp != NULL || retdatap != NULL ); - if( retoidp == NULL || retdatap == NULL ) { - ld->ld_errno = LDAP_PARAM_ERROR; - return( ld->ld_errno ); - } - rc = ldap_extended_operation( ld, reqoid, reqdata, sctrls, cctrls, &msgid ); diff --git a/libraries/libldap/getdn.c b/libraries/libldap/getdn.c index bec27bc7da..37e9a827ab 100644 --- a/libraries/libldap/getdn.c +++ b/libraries/libldap/getdn.c @@ -90,10 +90,7 @@ ldap_get_dn( LDAP *ld, LDAPMessage *entry ) Debug( LDAP_DEBUG_TRACE, "ldap_get_dn\n", 0, 0, 0 ); #endif - if ( entry == NULL ) { - ld->ld_errno = LDAP_PARAM_ERROR; - return( NULL ); - } + assert( entry != NULL ); tmp = *entry->lm_ber; /* struct copy */ if ( ber_scanf( &tmp, "{a" /*}*/, &dn ) == LBER_ERROR ) { @@ -2878,7 +2875,7 @@ ldap_rdn2bv( LDAPRDN *rdn, struct berval *bv, unsigned flags ) break; default: - return( LDAP_PARAM_ERROR ); + return LDAP_PARAM_ERROR; } bv->bv_val = LDAP_MALLOC( l + 1 ); diff --git a/libraries/libldap/getentry.c b/libraries/libldap/getentry.c index 37e601a6f5..b75a4403f4 100644 --- a/libraries/libldap/getentry.c +++ b/libraries/libldap/getentry.c @@ -97,9 +97,7 @@ ldap_get_entry_controls( assert( entry != NULL ); assert( sctrls != NULL ); - if ( ld == NULL || sctrls == NULL || - entry == NULL || entry->lm_msgtype != LDAP_RES_SEARCH_ENTRY ) - { + if ( entry->lm_msgtype != LDAP_RES_SEARCH_ENTRY ) { return LDAP_PARAM_ERROR; } diff --git a/libraries/libldap/references.c b/libraries/libldap/references.c index a5e5afefd0..2aae3f469c 100644 --- a/libraries/libldap/references.c +++ b/libraries/libldap/references.c @@ -26,10 +26,6 @@ ldap_first_reference( LDAP *ld, LDAPMessage *chain ) assert( LDAP_VALID( ld ) ); assert( chain != NULL ); - if ( ld == NULL || chain == NULL ) { - return NULL; - } - return chain->lm_msgtype == LDAP_RES_SEARCH_REFERENCE ? chain : ldap_next_reference( ld, chain ); @@ -42,10 +38,6 @@ ldap_next_reference( LDAP *ld, LDAPMessage *ref ) assert( LDAP_VALID( ld ) ); assert( ref != NULL ); - if ( ld == NULL || ref == NULL ) { - return NULL; - } - for ( ref = ref->lm_chain; ref != NULL; @@ -98,9 +90,7 @@ ldap_parse_reference( assert( LDAP_VALID( ld ) ); assert( ref != NULL ); - if( ld == NULL || ref == NULL || - ref->lm_msgtype != LDAP_RES_SEARCH_REFERENCE ) - { + if( ref->lm_msgtype != LDAP_RES_SEARCH_REFERENCE ) { return LDAP_PARAM_ERROR; } diff --git a/libraries/libldap/result.c b/libraries/libldap/result.c index f409afcc9e..a1ee317cf6 100644 --- a/libraries/libldap/result.c +++ b/libraries/libldap/result.c @@ -103,15 +103,6 @@ ldap_result( Debug( LDAP_DEBUG_TRACE, "ldap_result msgid %d\n", msgid, 0, 0 ); #endif - if( ld == NULL ) { - return -1; - } - - if( result == NULL ) { - ld->ld_errno = LDAP_PARAM_ERROR; - return -1; - } - lm = chkResponseList(ld, msgid, all); if ( lm == NULL ) { diff --git a/libraries/libldap/sasl.c b/libraries/libldap/sasl.c index 93a52472f8..0164bc962f 100644 --- a/libraries/libldap/sasl.c +++ b/libraries/libldap/sasl.c @@ -75,11 +75,6 @@ ldap_sasl_bind( rc = ldap_int_client_controls( ld, cctrls ); if( rc != LDAP_SUCCESS ) return rc; - if( msgidp == NULL ) { - ld->ld_errno = LDAP_PARAM_ERROR; - return ld->ld_errno; - } - if( mechanism == LDAP_SASL_SIMPLE ) { if( dn == NULL && cred != NULL ) { /* use default binddn */ @@ -269,10 +264,6 @@ ldap_parse_sasl_bind_result( assert( LDAP_VALID( ld ) ); assert( res != NULL ); - if ( ld == NULL || res == NULL ) { - return LDAP_PARAM_ERROR; - } - if( servercredp != NULL ) { if( ld->ld_version < LDAP_VERSION2 ) { return LDAP_NOT_SUPPORTED; diff --git a/libraries/libldap/sort.c b/libraries/libldap/sort.c index 706f8a768d..84557eb33a 100644 --- a/libraries/libldap/sort.c +++ b/libraries/libldap/sort.c @@ -90,13 +90,11 @@ ldap_sort_entries( LDAPMessage *e, *last; LDAPMessage **ep; - count = ldap_count_entries( ld, *chain ); + assert( ld != NULL ); + count = ldap_count_entries( ld, *chain ); if ( count < 0 ) { - if( ld != NULL ) { - ld->ld_errno = LDAP_PARAM_ERROR; - } return -1; } else if ( count < 2 ) { diff --git a/libraries/libldap/sortctrl.c b/libraries/libldap/sortctrl.c index 23ea9f47d8..f215a839d2 100644 --- a/libraries/libldap/sortctrl.c +++ b/libraries/libldap/sortctrl.c @@ -177,9 +177,9 @@ ldap_create_sort_keylist ( LDAPSortKey ***sortKeyList, char *keyString ) char *nextKey; LDAPSortKey **keyList = NULL; - if (( sortKeyList == NULL ) || ( keyString == NULL )) { - return LDAP_PARAM_ERROR; - } + assert( sortKeyList != NULL ); + assert( keyString != NULL ); + *sortKeyList = NULL; /* Determine the number of sort keys so we can allocate memory. */ diff --git a/libraries/libldap/url.c b/libraries/libldap/url.c index 97059170b7..0975e9bdf9 100644 --- a/libraries/libldap/url.c +++ b/libraries/libldap/url.c @@ -886,10 +886,10 @@ ldap_url_parselist (LDAPURLDesc **ludlist, const char *url ) LDAPURLDesc *ludp; char **urls; - *ludlist = NULL; + assert( ludlist != NULL ); + assert( url != NULL ); - if (url == NULL) - return LDAP_PARAM_ERROR; + *ludlist = NULL; urls = ldap_str2charray(url, ", "); if (urls == NULL) @@ -923,10 +923,10 @@ ldap_url_parsehosts( LDAPURLDesc *ludp; char **specs, *p; - *ludlist = NULL; + assert( ludlist != NULL ); + assert( url != NULL ); - if (hosts == NULL) - return LDAP_PARAM_ERROR; + *ludlist = NULL; specs = ldap_str2charray(hosts, ", "); if (specs == NULL) diff --git a/libraries/libldap/vlvctrl.c b/libraries/libldap/vlvctrl.c index 63adab1772..b1638cfe89 100644 --- a/libraries/libldap/vlvctrl.c +++ b/libraries/libldap/vlvctrl.c @@ -79,10 +79,9 @@ ldap_create_vlv_control( LDAP *ld, ber_tag_t tag; BerElement *ber; - if ( (ld==NULL) || (vlvinfop==NULL) || (ctrlp == NULL) ) { - ld->ld_errno = LDAP_PARAM_ERROR; - return(ld->ld_errno); - } + assert( ld != NULL ); + assert( vlvinfop != NULL ); + assert( ctrlp != NULL ); if ((ber = ldap_alloc_ber_with_options(ld)) == NULL) { ld->ld_errno = LDAP_NO_MEMORY; @@ -203,15 +202,12 @@ ldap_parse_vlv_control( ber_tag_t tag, berTag; ber_len_t berLen; + assert( ld != NULL ); + if (contextp) { *contextp = NULL; /* Make sure we return a NULL if error occurs. */ } - if (ld == NULL) { - ld->ld_errno = LDAP_PARAM_ERROR; - return(ld->ld_errno); - } - if (ctrls == NULL) { ld->ld_errno = LDAP_CONTROL_NOT_FOUND; return(ld->ld_errno); -- 2.39.5