diff options
author | Andrew Bartlett <abartlet@samba.org> | 2013-06-22 17:01:42 +1000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2013-06-24 12:54:26 -0700 |
commit | 70cb7fd214041e8ffacc98de4dbde3ecd77bba85 (patch) | |
tree | 283bc4c5f644b13344fad93485ed4160b371efa4 /libcli/ldap | |
parent | 4ca963926938917bf32af4eead61ded2a8275139 (diff) | |
download | samba-70cb7fd214041e8ffacc98de4dbde3ecd77bba85.tar.gz samba-70cb7fd214041e8ffacc98de4dbde3ecd77bba85.tar.bz2 samba-70cb7fd214041e8ffacc98de4dbde3ecd77bba85.zip |
libcli/ldap: Cope with substring match with no chunks in ldap_push_filter
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'libcli/ldap')
-rw-r--r-- | libcli/ldap/ldap_message.c | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/libcli/ldap/ldap_message.c b/libcli/ldap/ldap_message.c index f640bf34ed..1c5542c0d9 100644 --- a/libcli/ldap/ldap_message.c +++ b/libcli/ldap/ldap_message.c @@ -269,26 +269,29 @@ static bool ldap_push_filter(struct asn1_data *data, struct ldb_parse_tree *tree asn1_push_tag(data, ASN1_CONTEXT(4)); asn1_write_OctetString(data, tree->u.substring.attr, strlen(tree->u.substring.attr)); asn1_push_tag(data, ASN1_SEQUENCE(0)); - i = 0; - if ( ! tree->u.substring.start_with_wildcard) { - asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(0)); - asn1_write_DATA_BLOB_LDAPString(data, tree->u.substring.chunks[i]); - asn1_pop_tag(data); - i++; - } - while (tree->u.substring.chunks[i]) { - int ctx; - if (( ! tree->u.substring.chunks[i + 1]) && - (tree->u.substring.end_with_wildcard == 0)) { - ctx = 2; - } else { - ctx = 1; + if (tree->u.substring.chunks && tree->u.substring.chunks[0]) { + i = 0; + if (!tree->u.substring.start_with_wildcard) { + asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(0)); + asn1_write_DATA_BLOB_LDAPString(data, tree->u.substring.chunks[i]); + asn1_pop_tag(data); + i++; + } + while (tree->u.substring.chunks[i]) { + int ctx; + + if (( ! tree->u.substring.chunks[i + 1]) && + (tree->u.substring.end_with_wildcard == 0)) { + ctx = 2; + } else { + ctx = 1; + } + asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(ctx)); + asn1_write_DATA_BLOB_LDAPString(data, tree->u.substring.chunks[i]); + asn1_pop_tag(data); + i++; } - asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(ctx)); - asn1_write_DATA_BLOB_LDAPString(data, tree->u.substring.chunks[i]); - asn1_pop_tag(data); - i++; } asn1_pop_tag(data); asn1_pop_tag(data); |