summaryrefslogtreecommitdiff
path: root/source3/libsmb/asn1.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-11-27 23:40:54 -0800
committerJeremy Allison <jra@samba.org>2007-11-27 23:40:54 -0800
commit3daafc5662825228219e986a9fa570824b2104a8 (patch)
treec7edaf78effafcc887550f7aefa0c9a4f1a49f0d /source3/libsmb/asn1.c
parent762fde90a0cb3a3a82adc4f9e96dff8cac4ca527 (diff)
downloadsamba-3daafc5662825228219e986a9fa570824b2104a8.tar.gz
samba-3daafc5662825228219e986a9fa570824b2104a8.tar.bz2
samba-3daafc5662825228219e986a9fa570824b2104a8.zip
Remove pstrings from asn1.c.
Jeremy. (This used to be commit 82f393e60378eb42ddcc740241902eee495719d3)
Diffstat (limited to 'source3/libsmb/asn1.c')
-rw-r--r--source3/libsmb/asn1.c39
1 files changed, 28 insertions, 11 deletions
diff --git a/source3/libsmb/asn1.c b/source3/libsmb/asn1.c
index 0cbfa70e7b..99c5b0b1bd 100644
--- a/source3/libsmb/asn1.c
+++ b/source3/libsmb/asn1.c
@@ -348,22 +348,30 @@ int asn1_tag_remaining(ASN1_DATA *data)
/* read an object ID from a ASN1 buffer */
bool asn1_read_OID(ASN1_DATA *data, char **OID)
{
- uint8 b;
- pstring oid_str;
- fstring el;
+ uint8 b = 0;
+ char *oid_str = NULL;
*OID = NULL;
if (!asn1_start_tag(data, ASN1_OID)) {
- return False;
+ return false;
}
asn1_read_uint8(data, &b);
- oid_str[0] = 0;
- fstr_sprintf(el, "%u", b/40);
- pstrcat(oid_str, el);
- fstr_sprintf(el, " %u", b%40);
- pstrcat(oid_str, el);
+ oid_str = talloc_asprintf(NULL,
+ "%u",
+ b/40);
+ if (!oid_str) {
+ data->has_error = true;
+ goto out;
+ }
+ oid_str = talloc_asprintf_append(oid_str,
+ " %u",
+ b%40);
+ if (!oid_str) {
+ data->has_error = true;
+ goto out;
+ }
while (asn1_tag_remaining(data) > 0) {
unsigned v = 0;
@@ -371,16 +379,25 @@ bool asn1_read_OID(ASN1_DATA *data, char **OID)
asn1_read_uint8(data, &b);
v = (v<<7) | (b&0x7f);
} while (!data->has_error && b & 0x80);
- fstr_sprintf(el, " %u", v);
- pstrcat(oid_str, el);
+ oid_str = talloc_asprintf_append(oid_str,
+ " %u",
+ v);
+ if (!oid_str) {
+ data->has_error = true;
+ goto out;
+ }
}
+ out:
+
asn1_end_tag(data);
if (!data->has_error) {
*OID = SMB_STRDUP(oid_str);
}
+ TALLOC_FREE(oid_str);
+
return !data->has_error;
}