Clarify structure of parsing with comments:
1. Parse through to get the required buffer length. 2. Having allocated a buffer, parse into the buffer. Signed-off-by: David Horstmann <david.horstmann@arm.com>
This commit is contained in:
parent
89d67bd472
commit
376e8df9d6
1 changed files with 5 additions and 1 deletions
|
@ -954,6 +954,8 @@ int mbedtls_oid_from_numeric_string(mbedtls_asn1_buf *oid,
|
|||
size_t encoded_len;
|
||||
unsigned int component1, component2;
|
||||
|
||||
/* First pass - parse the string to get the length of buffer required */
|
||||
|
||||
ret = oid_parse_number(&component1, &str_ptr, str_bound);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
|
@ -1014,7 +1016,9 @@ int mbedtls_oid_from_numeric_string(mbedtls_asn1_buf *oid,
|
|||
}
|
||||
oid->len = encoded_len;
|
||||
|
||||
/* Now that we've allocated the buffer, go back to the start and encode */
|
||||
/* Second pass - now that we've allocated the buffer, go back to the
|
||||
* start and encode */
|
||||
|
||||
str_ptr = oid_str;
|
||||
unsigned char *out_ptr = oid->p;
|
||||
unsigned char *out_bound = oid->p + oid->len;
|
||||
|
|
Loading…
Reference in a new issue