1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

s4/drsuapi: Internal implementation for ber_read_OID_String

Modified implementation _ber_read_OID_String_impl()
returns how much bytes are converted.
The intentation is to use this implementation both for
reading OIDs and partial-OIDs in the future
This commit is contained in:
Kamen Mazdrashki 2009-09-25 17:28:33 +03:00 committed by Matthias Dieter Wallnöfer
parent 715c790600
commit 55dfc116f4

View File

@ -578,6 +578,46 @@ int asn1_tag_remaining(struct asn1_data *data)
return remaining;
}
/**
* Internal implementation for reading binary OIDs
* Reading is done as far in the buffer as valid OID
* till buffer ends or not valid sub-identifier is found.
*/
static bool _ber_read_OID_String_impl(TALLOC_CTX *mem_ctx, DATA_BLOB blob,
const char **OID, size_t *bytes_eaten)
{
int i;
uint8_t *b;
uint_t v;
char *tmp_oid = NULL;
if (blob.length < 2) return false;
b = blob.data;
tmp_oid = talloc_asprintf(mem_ctx, "%u", b[0]/40);
if (!tmp_oid) goto nomem;
tmp_oid = talloc_asprintf_append_buffer(tmp_oid, ".%u", b[0]%40);
if (!tmp_oid) goto nomem;
for(i = 1, v = 0; i < blob.length; i++) {
v = (v<<7) | (b[i]&0x7f);
if ( ! (b[i] & 0x80)) {
tmp_oid = talloc_asprintf_append_buffer(tmp_oid, ".%u", v);
v = 0;
if (bytes_eaten)
*bytes_eaten = i+1;
}
if (!tmp_oid) goto nomem;
}
*OID = tmp_oid;
return true;
nomem:
return false;
}
/* read an object ID from a data blob */
bool ber_read_OID_String(TALLOC_CTX *mem_ctx, DATA_BLOB blob, const char **OID)
{