From: Hallvard Furuseth Date: Fri, 23 Jun 2017 09:55:36 +0000 (+0100) Subject: ITS#8733 Allow extraction of the complete ber element X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=62811e8f654e7b437e0da42fa7a4fcd17cd39650;p=openldap ITS#8733 Allow extraction of the complete ber element --- diff --git a/include/lber.h b/include/lber.h index b93d8e3b6b..e0ea43d4aa 100644 --- a/include/lber.h +++ b/include/lber.h @@ -255,6 +255,11 @@ ber_peek_tag LDAP_P(( BerElement *ber, ber_len_t *len )); +LBER_F( ber_tag_t ) +ber_skip_raw LDAP_P(( + BerElement *ber, + struct berval *bv )); + LBER_F( ber_tag_t ) ber_skip_element LDAP_P(( BerElement *ber, diff --git a/libraries/liblber/decode.c b/libraries/liblber/decode.c index 4ee83263ae..7de08229f8 100644 --- a/libraries/liblber/decode.c +++ b/libraries/liblber/decode.c @@ -234,6 +234,25 @@ ber_skip_element( BerElement *ber, struct berval *bv ) return tag; } +/* Move past next element, point *bv at the complete element in-place, and + * return its tag. The caller may \0-terminate *bv, as next octet is saved in + * ber->ber_tag. Similar to ber_skip_element(ber, bv) except the tag+length + * header is also included in *bv. + */ +ber_tag_t +ber_skip_raw( BerElement *ber, struct berval *bv ) +{ + char *val = ber->ber_ptr; + ber_tag_t tag = ber_skip_element( ber, bv ); + + if ( tag != LBER_DEFAULT ) { + bv->bv_len += bv->bv_val - val; + bv->bv_val = val; + } + + return tag; +} + ber_tag_t ber_peek_tag( BerElement *ber,