ITS#1701. Fix ber_scanf() return tag handling.

Based upon patch submitted by Hallvard B. Furuseth <h.b.furuseth@usit.uio.no>.
This commit is contained in:
Kurt Zeilenga 2002-04-02 18:40:04 +00:00
parent e3dcb0481e
commit 26b99bc35d
6 changed files with 37 additions and 32 deletions

View 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 );
}

View 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;
}

View 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;
}

View 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 ));

View 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" ));

View 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"));