version 1.34.6.10, 2002/01/04 20:38:18
|
version 1.56, 2000/10/12 18:02:16
|
Line 1
|
Line 1
|
/* decode.c - ber input decoding routines */ |
/* decode.c - ber input decoding routines */ |
/* $OpenLDAP: pkg/ldap/libraries/liblber/decode.c,v 1.34.6.9 2001/12/04 18:49:15 kurt Exp $ */ |
/* $OpenLDAP: pkg/ldap/libraries/liblber/decode.c,v 1.55 2000/10/11 00:43:14 kurt Exp $ */ |
/* |
/* |
* Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved. |
* Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved. |
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file |
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file |
*/ |
*/ |
/* Portions |
/* Portions |
Line 137 ber_skip_tag( BerElement *ber, ber_len_t
|
Line 137 ber_skip_tag( BerElement *ber, ber_len_t
|
*len = lc; |
*len = lc; |
} |
} |
|
|
/* BER element should have enough data left */ |
|
if( *len > ber_pvt_ber_remaining( ber ) ) { |
|
return LBER_DEFAULT; |
|
} |
|
|
|
return tag; |
return tag; |
} |
} |
|
|
Line 257 ber_get_stringb(
|
Line 252 ber_get_stringb(
|
if ( (tag = ber_skip_tag( ber, &datalen )) == LBER_DEFAULT ) { |
if ( (tag = ber_skip_tag( ber, &datalen )) == LBER_DEFAULT ) { |
return LBER_DEFAULT; |
return LBER_DEFAULT; |
} |
} |
|
if ( datalen > (*len - 1) ) { |
/* must fit within allocated space with termination */ |
|
if ( datalen >= *len ) { |
|
return LBER_DEFAULT; |
return LBER_DEFAULT; |
} |
} |
|
|
Line 501 ber_scanf ( BerElement *ber,
|
Line 494 ber_scanf ( BerElement *ber,
|
|
|
fmt_reset = fmt; |
fmt_reset = fmt; |
|
|
|
LDAP_LOG( "LIBLBER", LDAP_LEVEL_ENTRY, "ber_scanf fmt (%s) ber:\n", fmt ); |
|
|
ber_log_printf( LDAP_DEBUG_TRACE, ber->ber_debug, |
ber_log_printf( LDAP_DEBUG_TRACE, ber->ber_debug, |
"ber_scanf fmt (%s) ber:\n", fmt ); |
"ber_scanf fmt (%s) ber:\n", fmt ); |
ber_log_dump( LDAP_DEBUG_BER, ber->ber_debug, ber, 1 ); |
ber_log_dump( LDAP_DEBUG_BER, ber->ber_debug, ber, 1 ); |
Line 585 ber_scanf ( BerElement *ber,
|
Line 580 ber_scanf ( BerElement *ber,
|
tag != LBER_DEFAULT && rc != LBER_DEFAULT; |
tag != LBER_DEFAULT && rc != LBER_DEFAULT; |
tag = ber_next_element( ber, &len, last ) ) |
tag = ber_next_element( ber, &len, last ) ) |
{ |
{ |
char **save = *sss; |
|
|
|
*sss = (char **) LBER_REALLOC( *sss, |
*sss = (char **) LBER_REALLOC( *sss, |
(j + 2) * sizeof(char *) ); |
(j + 2) * sizeof(char *) ); |
|
|
if( *sss == NULL ) { |
|
save[j] = NULL; |
|
ber_memvfree( (void **) save ); |
|
rc = LBER_DEFAULT; |
|
goto breakout; |
|
} |
|
|
|
rc = ber_get_stringa( ber, &((*sss)[j]) ); |
rc = ber_get_stringa( ber, &((*sss)[j]) ); |
j++; |
j++; |
} |
} |
if ( j > 0 ) (*sss)[j] = NULL; |
if ( j > 0 ) |
|
(*sss)[j] = NULL; |
break; |
break; |
|
|
case 'V': /* sequence of strings + lengths */ |
case 'V': /* sequence of strings + lengths */ |
Line 611 ber_scanf ( BerElement *ber,
|
Line 598 ber_scanf ( BerElement *ber,
|
tag != LBER_DEFAULT && rc != LBER_DEFAULT; |
tag != LBER_DEFAULT && rc != LBER_DEFAULT; |
tag = ber_next_element( ber, &len, last ) ) |
tag = ber_next_element( ber, &len, last ) ) |
{ |
{ |
struct berval **save = *bv; |
|
|
|
*bv = (struct berval **) LBER_REALLOC( *bv, |
*bv = (struct berval **) LBER_REALLOC( *bv, |
(j + 2) * sizeof(struct berval *) ); |
(j + 2) * sizeof(struct berval *) ); |
|
|
if( *bv == NULL ) { |
|
save[j] = NULL; |
|
ber_bvecfree( save ); |
|
rc = LBER_DEFAULT; |
|
goto breakout; |
|
} |
|
|
|
rc = ber_get_stringal( ber, &((*bv)[j]) ); |
rc = ber_get_stringal( ber, &((*bv)[j]) ); |
j++; |
j++; |
} |
} |
if ( j > 0 ) (*bv)[j] = NULL; |
if ( j > 0 ) |
|
(*bv)[j] = NULL; |
break; |
break; |
|
|
case 'x': /* skip the next element - whatever it is */ |
case 'x': /* skip the next element - whatever it is */ |
Line 655 ber_scanf ( BerElement *ber,
|
Line 634 ber_scanf ( BerElement *ber,
|
} |
} |
} |
} |
|
|
breakout: |
|
va_end( ap ); |
va_end( ap ); |
|
|
if ( rc == LBER_DEFAULT ) { |
if ( rc == LBER_DEFAULT ) { |
Line 734 breakout:
|
Line 712 breakout:
|
case 'v': /* sequence of strings */ |
case 'v': /* sequence of strings */ |
sss = va_arg( ap, char *** ); |
sss = va_arg( ap, char *** ); |
if ( *sss ) { |
if ( *sss ) { |
ber_memvfree( (void **) *sss ); |
for (j = 0; (*sss)[j]; j++) { |
|
LBER_FREE( (*sss)[j] ); |
|
(*sss)[j] = NULL; |
|
} |
|
LBER_FREE( *sss ); |
*sss = NULL; |
*sss = NULL; |
} |
} |
break; |
break; |