From 24c39b31b694b747c4832ad9824583164758d73b Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Mon, 21 Jun 1999 22:38:00 +0000 Subject: [PATCH] Add LDAP_VALID and other asserts. --- libraries/libldap/addentry.c | 6 ++++++ libraries/libldap/getattr.c | 2 +- libraries/libldap/getentry.c | 2 ++ libraries/libldap/getvalues.c | 10 ++++++++++ libraries/libldap/references.c | 6 +++++- 5 files changed, 24 insertions(+), 2 deletions(-) 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 || -- 2.39.5