From: Kurt Zeilenga Date: Mon, 21 Jun 1999 22:38:00 +0000 (+0000) Subject: Add LDAP_VALID and other asserts. X-Git-Tag: OPENLDAP_REL_ENG_2_BP~250 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=24c39b31b694b747c4832ad9824583164758d73b;p=openldap Add LDAP_VALID and other asserts. --- diff --git a/libraries/libldap/addentry.c b/libraries/libldap/addentry.c index 31d85ab5fe..13b0e0224d 100644 --- a/libraries/libldap/addentry.c +++ b/libraries/libldap/addentry.c @@ -27,6 +27,9 @@ ldap_delete_result_entry( LDAPMessage **list, LDAPMessage *e ) { LDAPMessage *tmp, *prev = NULL; + assert( list != NULL ); + assert( e != NULL ); + for ( tmp = *list; tmp != NULL && tmp != e; tmp = tmp->lm_chain ) prev = tmp; @@ -45,6 +48,9 @@ ldap_delete_result_entry( LDAPMessage **list, LDAPMessage *e ) void ldap_add_result_entry( LDAPMessage **list, LDAPMessage *e ) { + assert( list != NULL ); + assert( e != NULL ); + e->lm_chain = *list; *list = e; } diff --git a/libraries/libldap/getattr.c b/libraries/libldap/getattr.c index 07e8e27a44..1af9881381 100644 --- a/libraries/libldap/getattr.c +++ b/libraries/libldap/getattr.c @@ -46,7 +46,7 @@ ldap_first_attribute( LDAP *ld, LDAPMessage *entry, BerElement **ber ) * positioned right before the next attribute type/value sequence. */ - if ( ber_scanf( *ber, "{x{{ax}", &attr ) + if ( ber_scanf( *ber, "{x{{ax}" /*}}*/, &attr ) == LBER_ERROR ) { ld->ld_errno = LDAP_DECODING_ERROR; ber_free( *ber, 0 ); diff --git a/libraries/libldap/getentry.c b/libraries/libldap/getentry.c index 272ea304ad..6e5d15eb68 100644 --- a/libraries/libldap/getentry.c +++ b/libraries/libldap/getentry.c @@ -27,6 +27,7 @@ ldap_first_entry( LDAP *ld, LDAPMessage *chain ) { assert( ld != NULL ); assert( LDAP_VALID( ld ) ); + assert( chain != NULL ); if( ld == NULL || chain == NULL ) { return NULL; @@ -42,6 +43,7 @@ ldap_next_entry( LDAP *ld, LDAPMessage *entry ) { assert( ld != NULL ); assert( LDAP_VALID( ld ) ); + assert( entry != NULL ); if ( ld == NULL || entry == NULL ) { return NULL; diff --git a/libraries/libldap/getvalues.c b/libraries/libldap/getvalues.c index f384ca9b41..1ac26f447a 100644 --- a/libraries/libldap/getvalues.c +++ b/libraries/libldap/getvalues.c @@ -30,6 +30,11 @@ ldap_get_values( LDAP *ld, LDAPMessage *entry, LDAP_CONST char *target ) int found = 0; char **vals; + assert( ld != NULL ); + assert( LDAP_VALID( ld ) ); + assert( entry != NULL ); + assert( target != NULL ); + Debug( LDAP_DEBUG_TRACE, "ldap_get_values\n", 0, 0, 0 ); ber = *entry->lm_ber; @@ -82,6 +87,11 @@ ldap_get_values_len( LDAP *ld, LDAPMessage *entry, LDAP_CONST char *target ) int found = 0; struct berval **vals; + assert( ld != NULL ); + assert( LDAP_VALID( ld ) ); + assert( entry != NULL ); + assert( target != NULL ); + Debug( LDAP_DEBUG_TRACE, "ldap_get_values_len\n", 0, 0, 0 ); ber = *entry->lm_ber; diff --git a/libraries/libldap/references.c b/libraries/libldap/references.c index 50cf0fc27c..4ec4d91bb6 100644 --- a/libraries/libldap/references.c +++ b/libraries/libldap/references.c @@ -19,11 +19,11 @@ #include "ldap-int.h" -/* ARGSUSED */ LDAPMessage * ldap_first_reference( LDAP *ld, LDAPMessage *chain ) { assert( ld != NULL ); + assert( LDAP_VALID( ld ) ); assert( chain != NULL ); if ( ld == NULL || chain == NULL ) { @@ -39,6 +39,7 @@ LDAPMessage * ldap_next_reference( LDAP *ld, LDAPMessage *ref ) { assert( ld != NULL ); + assert( LDAP_VALID( ld ) ); assert( ref != NULL ); if ( ld == NULL || ref == NULL ) { @@ -64,12 +65,14 @@ ldap_count_references( LDAP *ld, LDAPMessage *chain ) int i; assert( ld != NULL ); + assert( LDAP_VALID( ld ) ); assert( chain != NULL ); if ( ld == NULL ) { return -1; } + for ( i = 0; chain != NULL; chain = chain->lm_chain ) { if( chain->lm_msgtype == LDAP_RES_SEARCH_REFERENCE ) { i++; @@ -92,6 +95,7 @@ ldap_parse_reference( int rc; assert( ld != NULL ); + assert( LDAP_VALID( ld ) ); assert( ref != NULL ); if( ld == NULL || ref == NULL ||