From: Garming Sam Date: Fri, 4 Mar 2016 01:46:46 +0000 (+1300) Subject: ldap VLV: correct ASN1 parsing of VLV requests X-Git-Tag: tdb-1.3.9~477 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fe2bcf9d4155527112c9089fe81ac0b2bfbd2ecb;p=thirdparty%2Fsamba.git ldap VLV: correct ASN1 parsing of VLV requests As with the encoding, the ASN1_CONTEXT tag isn't followed by an ASN1_SEQUENCE, though you wouldn't think that from reading the specification. Pair-programmed-with: Douglas Bagnall Signed-off-by: Garming Sam Reviewed-by: Andrew Bartlett --- diff --git a/source4/libcli/ldap/ldap_controls.c b/source4/libcli/ldap/ldap_controls.c index 98e690d0505..4192e42b489 100644 --- a/source4/libcli/ldap/ldap_controls.c +++ b/source4/libcli/ldap/ldap_controls.c @@ -117,9 +117,9 @@ static bool decode_server_sort_request(void *mem_ctx, DATA_BLOB in, void *_out) if (!lssc [num]->attributeName) { return false; } - - if (asn1_peek_tag(data, ASN1_OCTET_STRING)) { - if (!asn1_read_OctetString(data, mem_ctx, &rule)) { + + if (asn1_peek_tag(data, ASN1_CONTEXT_SIMPLE(0))) { + if (!asn1_read_ContextSimple(data, mem_ctx, 0, &rule)) { return false; } lssc[num]->orderingRule = talloc_strndup(lssc[num], (const char *)rule.data, rule.length); @@ -557,12 +557,8 @@ static bool decode_vlv_request(void *mem_ctx, DATA_BLOB in, void *_out) if (asn1_peek_tag(data, ASN1_CONTEXT(0))) { lvrc->type = 0; - - if (!asn1_start_tag(data, ASN1_CONTEXT(0))) { - return false; - } - if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) { + if (!asn1_start_tag(data, ASN1_CONTEXT(0))) { return false; } @@ -574,10 +570,6 @@ static bool decode_vlv_request(void *mem_ctx, DATA_BLOB in, void *_out) return false; } - if (!asn1_end_tag(data)) { /*SEQUENCE*/ - return false; - } - if (!asn1_end_tag(data)) { /*CONTEXT*/ return false; } @@ -586,13 +578,10 @@ static bool decode_vlv_request(void *mem_ctx, DATA_BLOB in, void *_out) lvrc->type = 1; - if (!asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(1))) { + if (!asn1_read_ContextSimple(data, mem_ctx, 1, &assertion_value)){ return false; } - if (!asn1_read_OctetString(data, mem_ctx, &assertion_value)) { - return false; - } lvrc->match.gtOrEq.value_len = assertion_value.length; if (lvrc->match.gtOrEq.value_len) { lvrc->match.gtOrEq.value = talloc_memdup(lvrc, assertion_value.data, assertion_value.length); @@ -603,10 +592,6 @@ static bool decode_vlv_request(void *mem_ctx, DATA_BLOB in, void *_out) } else { lvrc->match.gtOrEq.value = NULL; } - - if (!asn1_end_tag(data)) { /*CONTEXT*/ - return false; - } } if (asn1_peek_tag(data, ASN1_OCTET_STRING)) {