mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-01-06 10:46:21 +08:00
Prep for in-place parsing. Cache a ber_tag byte.
No visible impact from these changes.
This commit is contained in:
parent
0c36372134
commit
b92e0011dd
@ -44,10 +44,16 @@ ber_get_tag( BerElement *ber )
|
|||||||
assert( ber != NULL );
|
assert( ber != NULL );
|
||||||
assert( LBER_VALID( ber ) );
|
assert( LBER_VALID( ber ) );
|
||||||
|
|
||||||
if ( ber_read( ber, (char *) &xbyte, 1 ) != 1 ) {
|
if ( ber_pvt_ber_remaining( ber ) < 1 ) {
|
||||||
return LBER_DEFAULT;
|
return LBER_DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( ber->ber_ptr == ber->ber_buf )
|
||||||
|
xbyte = *ber->ber_ptr;
|
||||||
|
else
|
||||||
|
xbyte = ber->ber_tag;
|
||||||
|
ber->ber_ptr++;
|
||||||
|
|
||||||
tag = xbyte;
|
tag = xbyte;
|
||||||
|
|
||||||
if ( (xbyte & LBER_BIG_TAG_MASK) != LBER_BIG_TAG_MASK ) {
|
if ( (xbyte & LBER_BIG_TAG_MASK) != LBER_BIG_TAG_MASK ) {
|
||||||
@ -146,6 +152,7 @@ ber_skip_tag( BerElement *ber, ber_len_t *len )
|
|||||||
if( *len > (ber_len_t) ber_pvt_ber_remaining( ber ) ) {
|
if( *len > (ber_len_t) ber_pvt_ber_remaining( ber ) ) {
|
||||||
return LBER_DEFAULT;
|
return LBER_DEFAULT;
|
||||||
}
|
}
|
||||||
|
ber->ber_tag = *ber->ber_ptr;
|
||||||
|
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
@ -161,11 +168,13 @@ ber_peek_tag(
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
char *save;
|
char *save;
|
||||||
ber_tag_t tag;
|
ber_tag_t tag, old;
|
||||||
|
|
||||||
|
old = ber->ber_tag;
|
||||||
save = ber->ber_ptr;
|
save = ber->ber_ptr;
|
||||||
tag = ber_skip_tag( ber, len );
|
tag = ber_skip_tag( ber, len );
|
||||||
ber->ber_ptr = save;
|
ber->ber_ptr = save;
|
||||||
|
ber->ber_tag = old;
|
||||||
|
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
@ -213,6 +222,7 @@ ber_getnint(
|
|||||||
} else {
|
} else {
|
||||||
*num = 0;
|
*num = 0;
|
||||||
}
|
}
|
||||||
|
ber->ber_tag = *ber->ber_ptr;
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
@ -271,6 +281,7 @@ ber_get_stringb(
|
|||||||
if ( (ber_len_t) ber_read( ber, buf, datalen ) != datalen ) {
|
if ( (ber_len_t) ber_read( ber, buf, datalen ) != datalen ) {
|
||||||
return LBER_DEFAULT;
|
return LBER_DEFAULT;
|
||||||
}
|
}
|
||||||
|
ber->ber_tag = *ber->ber_ptr;
|
||||||
|
|
||||||
buf[datalen] = '\0';
|
buf[datalen] = '\0';
|
||||||
|
|
||||||
@ -423,6 +434,7 @@ ber_get_stringbv( BerElement *ber, struct berval *bv )
|
|||||||
return LBER_DEFAULT;
|
return LBER_DEFAULT;
|
||||||
}
|
}
|
||||||
bv->bv_val[bv->bv_len] = '\0';
|
bv->bv_val[bv->bv_len] = '\0';
|
||||||
|
ber->ber_tag = *ber->ber_ptr;
|
||||||
|
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
@ -499,6 +511,7 @@ ber_get_bitstringa(
|
|||||||
*buf = NULL;
|
*buf = NULL;
|
||||||
return LBER_DEFAULT;
|
return LBER_DEFAULT;
|
||||||
}
|
}
|
||||||
|
ber->ber_tag = *ber->ber_ptr;
|
||||||
|
|
||||||
*blen = datalen * 8 - unusedbits;
|
*blen = datalen * 8 - unusedbits;
|
||||||
return tag;
|
return tag;
|
||||||
@ -520,6 +533,7 @@ ber_get_null( BerElement *ber )
|
|||||||
if ( len != 0 ) {
|
if ( len != 0 ) {
|
||||||
return LBER_DEFAULT;
|
return LBER_DEFAULT;
|
||||||
}
|
}
|
||||||
|
ber->ber_tag = *ber->ber_ptr;
|
||||||
|
|
||||||
return( tag );
|
return( tag );
|
||||||
}
|
}
|
||||||
@ -558,6 +572,7 @@ ber_first_element(
|
|||||||
*last = NULL;
|
*last = NULL;
|
||||||
return LBER_DEFAULT;
|
return LBER_DEFAULT;
|
||||||
}
|
}
|
||||||
|
ber->ber_tag = *ber->ber_ptr;
|
||||||
|
|
||||||
*last = ber->ber_ptr + *len;
|
*last = ber->ber_ptr + *len;
|
||||||
|
|
||||||
@ -743,6 +758,7 @@ ber_scanf ( BerElement *ber,
|
|||||||
if ( (rc = ber_skip_tag( ber, &len )) == LBER_DEFAULT )
|
if ( (rc = ber_skip_tag( ber, &len )) == LBER_DEFAULT )
|
||||||
break;
|
break;
|
||||||
ber->ber_ptr += len;
|
ber->ber_ptr += len;
|
||||||
|
ber->ber_tag = *ber->ber_ptr;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '{': /* begin sequence */
|
case '{': /* begin sequence */
|
||||||
|
@ -594,7 +594,7 @@ fill_buffer:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ber->ber_buf==NULL) {
|
if (ber->ber_buf==NULL) {
|
||||||
ber->ber_buf = (char *) LBER_MALLOC( ber->ber_len );
|
ber->ber_buf = (char *) LBER_MALLOC( ber->ber_len + 1 );
|
||||||
if (ber->ber_buf==NULL) {
|
if (ber->ber_buf==NULL) {
|
||||||
return LBER_DEFAULT;
|
return LBER_DEFAULT;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user