Author: abartlet
Date: 2007-12-27 07:47:11 +0000 (Thu, 27 Dec 2007)
New Revision: 26613

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=26613

Log:
Add a function to write a DATA_BLOB into an LDAPString.

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

Modified:
   branches/SAMBA_4_0/source/libcli/ldap/ldap.c
   branches/SAMBA_4_0/source/libcli/util/asn1.c


Changeset:
Modified: branches/SAMBA_4_0/source/libcli/ldap/ldap.c
===================================================================
--- branches/SAMBA_4_0/source/libcli/ldap/ldap.c        2007-12-27 07:45:22 UTC 
(rev 26612)
+++ branches/SAMBA_4_0/source/libcli/ldap/ldap.c        2007-12-27 07:47:11 UTC 
(rev 26613)
@@ -77,7 +77,7 @@
                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 @@
                                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 @@
                        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);

Modified: branches/SAMBA_4_0/source/libcli/util/asn1.c
===================================================================
--- branches/SAMBA_4_0/source/libcli/util/asn1.c        2007-12-27 07:45:22 UTC 
(rev 26612)
+++ branches/SAMBA_4_0/source/libcli/util/asn1.c        2007-12-27 07:47:11 UTC 
(rev 26613)
@@ -285,6 +285,13 @@
        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)
 {

Reply via email to