From 1890b720b426e699232f15fc05f850ae0837e199 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Sat, 30 Sep 2000 05:35:44 +0000 Subject: [PATCH] cleanup getattr bailout code --- libraries/libldap/getattr.c | 20 ++++++++++++-------- libraries/libldap/request.c | 8 ++++---- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/libraries/libldap/getattr.c b/libraries/libldap/getattr.c index 2c78f230b3..12c84fc0fb 100644 --- a/libraries/libldap/getattr.c +++ b/libraries/libldap/getattr.c @@ -60,13 +60,7 @@ ldap_first_attribute( LDAP *ld, LDAPMessage *entry, BerElement **berout ) return NULL; } -#if LDAP_SEQORSET_BAILOUT - if( len == 0 ) { - return NULL; - } -#endif - -#if LBER_SEQORSET_AVOID_OVERRUN +#ifdef LBER_SEQORSET_AVOID_OVERRUN /* set the length to avoid overrun */ rc = ber_set_option( ber, LBER_OPT_REMAINING_BYTES, &len ); if( rc != LBER_OPT_SUCCESS ) { @@ -74,6 +68,14 @@ ldap_first_attribute( LDAP *ld, LDAPMessage *entry, BerElement **berout ) ber_free( ber, 0 ); return NULL; } + +#ifdef LDAP_SEQORSET_BAILOUT + if ( ber_pvt_ber_remaining( ber ) == 0 ) { + assert( len == 0 ); + return NULL; + } + assert( len != 0 ); +#endif #endif /* snatch the first attribute */ @@ -102,10 +104,12 @@ ldap_next_attribute( LDAP *ld, LDAPMessage *entry, BerElement *ber ) assert( entry != NULL ); assert( ber != NULL ); -#if LDAP_SEQORSET_BAILOUT +#ifdef LBER_SEQORSET_AVOID_OVERRUN +#ifdef LDAP_SEQORSET_BAILOUT if ( ber_pvt_ber_remaining( ber ) == 0 ) { return NULL; } +#endif #endif /* skip sequence, snarf attribute type, skip values */ diff --git a/libraries/libldap/request.c b/libraries/libldap/request.c index b83cafba18..f069eae76b 100644 --- a/libraries/libldap/request.c +++ b/libraries/libldap/request.c @@ -953,9 +953,9 @@ ldap_append_referral( LDAP *ld, char **referralsp, char *s ) static BerElement * re_encode_request( LDAP *ld, BerElement *origber, ber_int_t msgid, char **dnp, int *type ) { -/* - * XXX this routine knows way too much about how the lber library works! - */ + /* + * XXX this routine knows way too much about how the lber library works! + */ ber_int_t along; ber_tag_t tag; ber_int_t ver; @@ -1050,7 +1050,7 @@ re_encode_request( LDAP *ld, BerElement *origber, ber_int_t msgid, char **dnp, i LDAPRequest * ldap_find_request_by_msgid( LDAP *ld, ber_int_t msgid ) { - LDAPRequest *lr; + LDAPRequest *lr; for ( lr = ld->ld_requests; lr != NULL; lr = lr->lr_next ) { if( lr->lr_status == LDAP_REQST_COMPLETED ) { -- 2.39.5