From 9d6b3e62c2dd27c7e8f72d6887888f686d868981 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 14 Jun 2005 03:52:27 +0000 Subject: r7566: added support for LDAPString types in the asn.1 library (This used to be commit 1a81d28456261ad77181fd12c0b4a9df6aa6a47d) --- source4/libcli/util/asn1.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index dff31f6411..510ffa37cf 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -214,11 +214,18 @@ BOOL asn1_write_OctetString(struct asn1_data *data, const void *p, size_t length return !data->has_error; } +/* write a LDAP string */ +BOOL asn1_write_LDAPString(struct asn1_data *data, const char *s) +{ + asn1_write(data, s, strlen(s)); + return !data->has_error; +} + /* write a general string */ BOOL asn1_write_GeneralString(struct asn1_data *data, const char *s) { asn1_push_tag(data, ASN1_GENERAL_STRING); - asn1_write(data, s, strlen(s)); + asn1_write_LDAPString(data, s); asn1_pop_tag(data); return !data->has_error; } @@ -477,11 +484,10 @@ BOOL asn1_check_OID(struct asn1_data *data, const char *OID) return True; } -/* read a GeneralString from a ASN1 buffer */ -BOOL asn1_read_GeneralString(struct asn1_data *data, char **s) +/* read a LDAPString from a ASN1 buffer */ +BOOL asn1_read_LDAPString(struct asn1_data *data, char **s) { int len; - if (!asn1_start_tag(data, ASN1_GENERAL_STRING)) return False; len = asn1_tag_remaining(data); if (len < 0) { data->has_error = True; @@ -494,10 +500,19 @@ BOOL asn1_read_GeneralString(struct asn1_data *data, char **s) } asn1_read(data, *s, len); (*s)[len] = 0; - asn1_end_tag(data); return !data->has_error; } + +/* read a GeneralString from a ASN1 buffer */ +BOOL asn1_read_GeneralString(struct asn1_data *data, char **s) +{ + if (!asn1_start_tag(data, ASN1_GENERAL_STRING)) return False; + if (!asn1_read_LDAPString(data, s)) return False; + return asn1_end_tag(data); +} + + /* read a octet string blob */ BOOL asn1_read_OctetString(struct asn1_data *data, DATA_BLOB *blob) { -- cgit