r26613: Add a function to write a DATA_BLOB into an LDAPString.
authorAndrew Bartlett <abartlet@samba.org>
Thu, 27 Dec 2007 13:47:11 +0000 (07:47 -0600)
committerStefan Metzmacher <metze@samba.org>
Thu, 27 Dec 2007 07:51:05 +0000 (01:51 -0600)
This respects the length set in the DATA_BLOB, rather than hoping to
see NULL termination of the data pointer.

(found testing the Ambigious Name Resolution code against OpenLDAP).

Andrew Bartlett

source/libcli/ldap/ldap.c
source/libcli/util/asn1.c

index 34d715e3e5ba17c4c67296c147b48d379b7dc2ea..586f2fa6531ca49200fb9720858d15c9ce8b2fe2 100644 (file)
@@ -77,7 +77,7 @@ static bool ldap_push_filter(struct asn1_data *data, struct ldb_parse_tree *tree
                i = 0;
                if ( ! tree->u.substring.start_with_wildcard) {
                        asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(0));
-                       asn1_write_LDAPString(data, (char *)tree->u.substring.chunks[i]->data);
+                       asn1_write_DATA_BLOB_LDAPString(data, tree->u.substring.chunks[i]);
                        asn1_pop_tag(data);
                        i++;
                }
@@ -91,7 +91,7 @@ static bool ldap_push_filter(struct asn1_data *data, struct ldb_parse_tree *tree
                                ctx = 1;
                        }
                        asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(ctx));
-                       asn1_write_LDAPString(data, (char *)tree->u.substring.chunks[i]->data);
+                       asn1_write_DATA_BLOB_LDAPString(data, tree->u.substring.chunks[i]);
                        asn1_pop_tag(data);
                        i++;
                }
@@ -157,7 +157,7 @@ static bool ldap_push_filter(struct asn1_data *data, struct ldb_parse_tree *tree
                        asn1_pop_tag(data);
                }
                asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(3));
-               asn1_write_LDAPString(data, (char *)tree->u.extended.value.data);
+               asn1_write_DATA_BLOB_LDAPString(data, &tree->u.extended.value);
                asn1_pop_tag(data);
                asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(4));
                asn1_write_uint8(data, tree->u.extended.dnAttributes);
index 58cb5f07beed369d228b003ad09f47acdc2a3bf5..ca6f0dc031c1621f084ed459c1dc996204e1872b 100644 (file)
@@ -285,6 +285,13 @@ bool asn1_write_LDAPString(struct asn1_data *data, const char *s)
        return !data->has_error;
 }
 
+/* write a LDAP string from a DATA_BLOB */
+bool asn1_write_DATA_BLOB_LDAPString(struct asn1_data *data, const DATA_BLOB *s)
+{
+       asn1_write(data, s->data, s->length);
+       return !data->has_error;
+}
+
 /* write a general string */
 bool asn1_write_GeneralString(struct asn1_data *data, const char *s)
 {