]> git.sur5r.net Git - openldap/commitdiff
ITS#1701. Fix ber_scanf() return tag handling.
authorKurt Zeilenga <kurt@openldap.org>
Tue, 2 Apr 2002 18:40:04 +0000 (18:40 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Tue, 2 Apr 2002 18:40:04 +0000 (18:40 +0000)
Based upon patch submitted by Hallvard B. Furuseth <h.b.furuseth@usit.uio.no>.

libraries/liblber/dtest.c
libraries/libldap/controls.c
libraries/libldap/request.c
servers/slapd/add.c
servers/slapd/ava.c
servers/slapd/mra.c

index 82fc6461dfe36470c5b1c5535fcad7e82f32ad09..6847e1539c590ff4ced5a382b6b987df60a289b6 100644 (file)
@@ -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 );
                }
index 1ad762b38461622b772e0c385e593ce569b8b4e1..9925357b0c2065a50d6764155424bd0f5b47eea2 100644 (file)
@@ -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;
        }
index b80a10d468e831198e1dc9b62363bae7d4e2cd6f..c963a0f166a0e2332bab55a877c7163a39ae8d9e 100644 (file)
@@ -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;
        }
index 328f294137473e8e34f488a6ad7493c17be2fd8f..5d222c5af0a81a920c87ad5f7610e94770339e58 100644 (file)
@@ -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 ));
index 72ddab449c762e0e24af56a6968cc104458f989b..c521993c54bf3b9c66c667357e96ec052b9b444d 100644 (file)
@@ -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" ));
index f3107156aaca9902143b41d1f6229300dcbcf65a..81db86ae7687473872714cc5460984a353f91f45 100644 (file)
@@ -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"));