From 26b99bc35dd1616cb986890bfe3fb130ffb9a8a4 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Tue, 2 Apr 2002 18:40:04 +0000 Subject: [PATCH] ITS#1701. Fix ber_scanf() return tag handling. Based upon patch submitted by Hallvard B. Furuseth . --- libraries/liblber/dtest.c | 11 ++++++----- libraries/libldap/controls.c | 2 +- libraries/libldap/request.c | 13 +++++++------ servers/slapd/add.c | 5 +++-- servers/slapd/ava.c | 5 +++-- servers/slapd/mra.c | 33 +++++++++++++++++---------------- 6 files changed, 37 insertions(+), 32 deletions(-) diff --git a/libraries/liblber/dtest.c b/libraries/liblber/dtest.c index 82fc6461df..6847e1539c 100644 --- a/libraries/liblber/dtest.c +++ b/libraries/liblber/dtest.c @@ -40,7 +40,6 @@ int main( int argc, char **argv ) { char *s; - int rc; ber_tag_t tag; ber_len_t len; @@ -68,12 +67,14 @@ main( int argc, char **argv ) ber_sockbuf_add_io( sb, &ber_sockbuf_io_fd, LBER_SBIOD_LEVEL_PROVIDER, (void *)&fd ); - if( (ber = ber_alloc_t(LBER_USE_DER)) == NULL ) { + ber = ber_alloc_t(LBER_USE_DER); + if( ber == NULL ) { perror( "ber_alloc_t" ); return( EXIT_FAILURE ); } - if(( tag = ber_get_next( sb, &len, ber) ) == LBER_ERROR ) { + tag = ber_get_next( sb, &len, ber); + if( tag == LBER_ERROR ) { perror( "ber_get_next" ); return( EXIT_FAILURE ); } @@ -89,9 +90,9 @@ main( int argc, char **argv ) printf("decode: format %s\n", fmt ); len = sizeof(buf); - rc = ber_scanf( ber, fmt, &buf[0], &len ); + tag = ber_scanf( ber, fmt, &buf[0], &len ); - if( rc == LBER_ERROR ) { + if( tag == LBER_ERROR ) { perror( "ber_scanf" ); return( EXIT_FAILURE ); } diff --git a/libraries/libldap/controls.c b/libraries/libldap/controls.c index 1ad762b384..9925357b0c 100644 --- a/libraries/libldap/controls.c +++ b/libraries/libldap/controls.c @@ -422,7 +422,7 @@ ldap_create_control( return LDAP_NO_MEMORY; } - if ( ber_flatten( ber, &bvalp ) == LBER_ERROR ) { + if ( ber_flatten( ber, &bvalp ) == -1 ) { LDAP_FREE( ctrl ); return LDAP_NO_MEMORY; } diff --git a/libraries/libldap/request.c b/libraries/libldap/request.c index b80a10d468..c963a0f166 100644 --- a/libraries/libldap/request.c +++ b/libraries/libldap/request.c @@ -1081,6 +1081,7 @@ re_encode_request( LDAP *ld, */ ber_int_t along; ber_tag_t tag; + ber_tag_t rtag; ber_int_t ver; ber_int_t scope; int rc; @@ -1108,9 +1109,9 @@ re_encode_request( LDAP *ld, * tagged with the operation code. For delete, the provided DN * is not wrapped by a sequence. */ - rc = ber_scanf( &tmpber, "{it", /*}*/ &along, &tag ); + rtag = ber_scanf( &tmpber, "{it", /*}*/ &along, &tag ); - if ( rc == LBER_ERROR ) { + if ( rtag == LBER_ERROR ) { ld->ld_errno = LDAP_DECODING_ERROR; return( NULL ); } @@ -1118,11 +1119,11 @@ re_encode_request( LDAP *ld, assert( tag != 0); if ( tag == LDAP_REQ_BIND ) { /* bind requests have a version number before the DN & other stuff */ - rc = ber_scanf( &tmpber, "{ia" /*}*/, &ver, &orig_dn ); + rtag = ber_scanf( &tmpber, "{ia" /*}*/, &ver, &orig_dn ); } else if ( tag == LDAP_REQ_DELETE ) { /* delete requests don't have a DN wrapping sequence */ - rc = ber_scanf( &tmpber, "a", &orig_dn ); + rtag = ber_scanf( &tmpber, "a", &orig_dn ); } else if ( tag == LDAP_REQ_SEARCH ) { /* search requests need to be re-scope-ed */ @@ -1141,10 +1142,10 @@ re_encode_request( LDAP *ld, } } else { - rc = ber_scanf( &tmpber, "{a" /*}*/, &orig_dn ); + rtag = ber_scanf( &tmpber, "{a" /*}*/, &orig_dn ); } - if( rc == LBER_ERROR ) { + if( rtag == LBER_ERROR ) { ld->ld_errno = LDAP_DECODING_ERROR; return NULL; } diff --git a/servers/slapd/add.c b/servers/slapd/add.c index 328f294137..5d222c5af0 100644 --- a/servers/slapd/add.c +++ b/servers/slapd/add.c @@ -109,10 +109,11 @@ do_add( Connection *conn, Operation *op ) tag = ber_next_element( ber, &len, last ) ) { Modifications *mod; + ber_tag_t rtag; - rc = ber_scanf( ber, "{m{W}}", &tmp.sml_type, &tmp.sml_bvalues ); + rtag = ber_scanf( ber, "{m{W}}", &tmp.sml_type, &tmp.sml_bvalues ); - if ( rc == LBER_ERROR ) { + if ( rtag == LBER_ERROR ) { #ifdef NEW_LOGGING LDAP_LOG(( "operation", LDAP_LEVEL_ERR, "do_add: conn %d decoding error \n", conn->c_connid )); diff --git a/servers/slapd/ava.c b/servers/slapd/ava.c index 72ddab449c..c521993c54 100644 --- a/servers/slapd/ava.c +++ b/servers/slapd/ava.c @@ -36,12 +36,13 @@ get_ava( ) { int rc; + ber_tag_t rtag; struct berval type, value; AttributeAssertion *aa; - rc = ber_scanf( ber, "{mm}", &type, &value ); + rtag = ber_scanf( ber, "{mm}", &type, &value ); - if( rc == LBER_ERROR ) { + if( rtag == LBER_ERROR ) { #ifdef NEW_LOGGING LDAP_LOG(( "filter", LDAP_LEVEL_ERR, "get_ava: ber_scanf failure\n" )); diff --git a/servers/slapd/mra.c b/servers/slapd/mra.c index f3107156aa..81db86ae76 100644 --- a/servers/slapd/mra.c +++ b/servers/slapd/mra.c @@ -34,7 +34,8 @@ get_mra( const char **text ) { - int rc, tag; + int rc; + ber_tag_t tag, rtag; ber_len_t length; struct berval type = { 0, NULL }, value; MatchingRuleAssertion *ma; @@ -48,9 +49,9 @@ get_mra( ma->ma_value.bv_len = 0; ma->ma_value.bv_val = NULL; - rc = ber_scanf( ber, "{t", &tag ); + rtag = ber_scanf( ber, "{t", &tag ); - if( rc == LBER_ERROR ) { + if( rtag == LBER_ERROR ) { #ifdef NEW_LOGGING LDAP_LOG(( "operation", LDAP_LEVEL_ERR, "get_mra: ber_scanf (\"{t\") failure\n" )); @@ -64,8 +65,8 @@ get_mra( } if ( tag == LDAP_FILTER_EXT_OID ) { - rc = ber_scanf( ber, "m", &ma->ma_rule_text ); - if ( rc == LBER_ERROR ) { + rtag = ber_scanf( ber, "m", &ma->ma_rule_text ); + if ( rtag == LBER_ERROR ) { #ifdef NEW_LOGGING LDAP_LOG(( "operation", LDAP_LEVEL_ERR, "get_mra: ber_scanf(\"o\") failure.\n" )); @@ -78,8 +79,8 @@ get_mra( return SLAPD_DISCONNECT; } - rc = ber_scanf( ber, "t", &tag ); - if( rc == LBER_ERROR ) { + rtag = ber_scanf( ber, "t", &tag ); + if( rtag == LBER_ERROR ) { #ifdef NEW_LOGGING LDAP_LOG(( "operation", LDAP_LEVEL_ERR, "get_mra: ber_scanf (\"t\") failure\n" )); @@ -94,8 +95,8 @@ get_mra( } if ( tag == LDAP_FILTER_EXT_TYPE ) { - rc = ber_scanf( ber, "m", &type ); - if ( rc == LBER_ERROR ) { + rtag = ber_scanf( ber, "m", &type ); + if ( rtag == LBER_ERROR ) { #ifdef NEW_LOGGING LDAP_LOG(( "operation", LDAP_LEVEL_ERR, "get_mra: ber_scanf (\"o\") failure.\n" )); @@ -107,8 +108,8 @@ get_mra( return SLAPD_DISCONNECT; } - rc = ber_scanf( ber, "t", &tag ); - if( rc == LBER_ERROR ) { + rtag = ber_scanf( ber, "t", &tag ); + if( rtag == LBER_ERROR ) { #ifdef NEW_LOGGING LDAP_LOG(( "operation", LDAP_LEVEL_ERR, "get_mra: ber_scanf (\"t\") failure.\n" )); @@ -135,9 +136,9 @@ get_mra( return SLAPD_DISCONNECT; } - rc = ber_scanf( ber, "m", &value ); + rtag = ber_scanf( ber, "m", &value ); - if( rc == LBER_ERROR ) { + if( rtag == LBER_ERROR ) { #ifdef NEW_LOGGING LDAP_LOG(( "operation", LDAP_LEVEL_ERR, "get_mra: ber_scanf (\"o\") failure.\n" )); @@ -153,12 +154,12 @@ get_mra( tag = ber_peek_tag( ber, &length ); if ( tag == LDAP_FILTER_EXT_DNATTRS ) { - rc = ber_scanf( ber, "b}", &ma->ma_dnattrs ); + rtag = ber_scanf( ber, "b}", &ma->ma_dnattrs ); } else { - rc = ber_scanf( ber, "}" ); + rtag = ber_scanf( ber, "}" ); } - if( rc == LBER_ERROR ) { + if( rtag == LBER_ERROR ) { #ifdef NEW_LOGGING LDAP_LOG(( "operation", LDAP_LEVEL_ERR, "get_mra: ber_scanf failure\n")); -- 2.39.5