summaryrefslogtreecommitdiff
path: root/source4/libcli/util
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-06-14 03:52:27 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:18:10 -0500
commit9d6b3e62c2dd27c7e8f72d6887888f686d868981 (patch)
tree75b3faa00aed0885c5cc264df60e5dba320a1018 /source4/libcli/util
parent2e8968714455be3f8f643faf3880f64ec4d65d5b (diff)
downloadsamba-9d6b3e62c2dd27c7e8f72d6887888f686d868981.tar.gz
samba-9d6b3e62c2dd27c7e8f72d6887888f686d868981.tar.bz2
samba-9d6b3e62c2dd27c7e8f72d6887888f686d868981.zip
r7566: added support for LDAPString types in the asn.1 library
(This used to be commit 1a81d28456261ad77181fd12c0b4a9df6aa6a47d)
Diffstat (limited to 'source4/libcli/util')
-rw-r--r--source4/libcli/util/asn1.c25
1 files changed, 20 insertions, 5 deletions
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)
{