1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-13 13:18:06 +03:00

Remove pstrings from asn1.c.

Jeremy.
This commit is contained in:
Jeremy Allison 2007-11-27 23:40:54 -08:00
parent 71ccd0c42e
commit 82f393e603

View File

@ -348,22 +348,30 @@ int asn1_tag_remaining(ASN1_DATA *data)
/* read an object ID from a ASN1 buffer */ /* read an object ID from a ASN1 buffer */
bool asn1_read_OID(ASN1_DATA *data, char **OID) bool asn1_read_OID(ASN1_DATA *data, char **OID)
{ {
uint8 b; uint8 b = 0;
pstring oid_str; char *oid_str = NULL;
fstring el;
*OID = NULL; *OID = NULL;
if (!asn1_start_tag(data, ASN1_OID)) { if (!asn1_start_tag(data, ASN1_OID)) {
return False; return false;
} }
asn1_read_uint8(data, &b); asn1_read_uint8(data, &b);
oid_str[0] = 0; oid_str = talloc_asprintf(NULL,
fstr_sprintf(el, "%u", b/40); "%u",
pstrcat(oid_str, el); b/40);
fstr_sprintf(el, " %u", b%40); if (!oid_str) {
pstrcat(oid_str, el); 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) { while (asn1_tag_remaining(data) > 0) {
unsigned v = 0; unsigned v = 0;
@ -371,16 +379,25 @@ bool asn1_read_OID(ASN1_DATA *data, char **OID)
asn1_read_uint8(data, &b); asn1_read_uint8(data, &b);
v = (v<<7) | (b&0x7f); v = (v<<7) | (b&0x7f);
} while (!data->has_error && b & 0x80); } while (!data->has_error && b & 0x80);
fstr_sprintf(el, " %u", v); oid_str = talloc_asprintf_append(oid_str,
pstrcat(oid_str, el); " %u",
v);
if (!oid_str) {
data->has_error = true;
goto out;
}
} }
out:
asn1_end_tag(data); asn1_end_tag(data);
if (!data->has_error) { if (!data->has_error) {
*OID = SMB_STRDUP(oid_str); *OID = SMB_STRDUP(oid_str);
} }
TALLOC_FREE(oid_str);
return !data->has_error; return !data->has_error;
} }