Commit 99f5983f authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

Consistently don't check for NULL session handle and other pointers.

Application is responsible for providing valid session pointers.
parent 19eca33c
......@@ -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 ) {
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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 );
......
......@@ -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 );
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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 ) {
......
......@@ -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;
......
......@@ -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 ) {
......
......@@ -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. */
......
......@@ -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)
......
......@@ -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);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment