X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libraries%2Fliblber%2Fdecode.c;h=ca24e89c3887ce58416fd44c5863d51a674ecd55;hb=8045b54124f0365b3d34d9d3220256f052f2b76b;hp=94a1c6ea14ab6aaae5b396c7570582fe4a90b91d;hpb=b1639dadd64cd24779a0ee2cc03c6028a4b1f7a3;p=openldap diff --git a/libraries/liblber/decode.c b/libraries/liblber/decode.c index 94a1c6ea14..ca24e89c38 100644 --- a/libraries/liblber/decode.c +++ b/libraries/liblber/decode.c @@ -1,7 +1,7 @@ /* decode.c - ber input decoding routines */ /* $OpenLDAP$ */ /* - * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file */ /* Portions @@ -39,7 +39,6 @@ ber_get_tag( BerElement *ber ) { unsigned char xbyte; ber_tag_t tag; - char *tagp; unsigned int i; assert( ber != NULL ); @@ -48,16 +47,17 @@ ber_get_tag( BerElement *ber ) if ( ber_read( ber, (char *) &xbyte, 1 ) != 1 ) return( LBER_DEFAULT ); + tag = xbyte; + if ( (xbyte & LBER_BIG_TAG_MASK) != LBER_BIG_TAG_MASK ) - return( (ber_tag_t) xbyte ); + return tag; - tagp = (char *) &tag; - tagp[0] = xbyte; for ( i = 1; i < sizeof(ber_tag_t); i++ ) { if ( ber_read( ber, (char *) &xbyte, 1 ) != 1 ) return( LBER_DEFAULT ); - tagp[i] = xbyte; + tag <<= 8; + tag |= 0x00ffUL & (ber_tag_t) xbyte; if ( ! (xbyte & LBER_MORE_TAG_MASK) ) break; @@ -67,8 +67,7 @@ ber_get_tag( BerElement *ber ) if ( i == sizeof(ber_tag_t) ) return( LBER_DEFAULT ); - /* want leading, not trailing 0's */ - return( tag >> (sizeof(ber_tag_t) - i - 1) ); + return tag; } ber_tag_t @@ -229,6 +228,14 @@ ber_get_int( return( tag ); } +ber_tag_t +ber_get_enum( + BerElement *ber, + ber_int_t *num ) +{ + return ber_get_int( ber, num ); +} + ber_tag_t ber_get_stringb( BerElement *ber,