Use for loop instead while loop
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
This commit is contained in:
parent
68ca81c8fe
commit
42510a91c4
1 changed files with 5 additions and 8 deletions
|
@ -90,22 +90,22 @@ int mbedtls_x509write_csr_set_subject_alternative_name(mbedtls_x509write_csr *ct
|
||||||
const mbedtls_x509_san_list *san_list)
|
const mbedtls_x509_san_list *san_list)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
const mbedtls_x509_san_list *cur = san_list;
|
const mbedtls_x509_san_list *cur;
|
||||||
unsigned char *buf;
|
unsigned char *buf;
|
||||||
unsigned char *p;
|
unsigned char *p;
|
||||||
size_t len;
|
size_t len;
|
||||||
size_t buflen = 0;
|
size_t buflen = 0;
|
||||||
|
|
||||||
/* Determine the maximum size of the SubjectAltName list */
|
/* Determine the maximum size of the SubjectAltName list */
|
||||||
while (cur != NULL) {
|
for(cur = san_list; cur != NULL; cur = cur->next) {
|
||||||
/* Calculate size of the required buffer */
|
/* Calculate size of the required buffer */
|
||||||
switch (cur->node.type) {
|
switch (cur->node.type) {
|
||||||
case MBEDTLS_X509_SAN_DNS_NAME:
|
case MBEDTLS_X509_SAN_DNS_NAME:
|
||||||
case MBEDTLS_X509_SAN_UNIFORM_RESOURCE_IDENTIFIER:
|
case MBEDTLS_X509_SAN_UNIFORM_RESOURCE_IDENTIFIER:
|
||||||
case MBEDTLS_X509_SAN_IP_ADDRESS:
|
case MBEDTLS_X509_SAN_IP_ADDRESS:
|
||||||
/* + length of value for each name entry,
|
/* length of value for each name entry,
|
||||||
* + maximum 4 bytes for the length field,
|
* maximum 4 bytes for the length field,
|
||||||
* + 1 byte for the tag/type.
|
* 1 byte for the tag/type.
|
||||||
*/
|
*/
|
||||||
buflen += cur->node.san.unstructured_name.len + 4 + 1;
|
buflen += cur->node.san.unstructured_name.len + 4 + 1;
|
||||||
break;
|
break;
|
||||||
|
@ -114,9 +114,6 @@ int mbedtls_x509write_csr_set_subject_alternative_name(mbedtls_x509write_csr *ct
|
||||||
/* Not supported - skip. */
|
/* Not supported - skip. */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cur = cur->next;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add the extra length field and tag */
|
/* Add the extra length field and tag */
|
||||||
|
|
Loading…
Reference in a new issue