mbedtls: CVE-2025-47917 fix

Backported from 3.6.x

Prevents crash and/or possible memory leak from invalid input
This commit is contained in:
Jeremy Newton 2025-10-31 22:14:19 -04:00
parent 44d047d496
commit a200df3566

View File

@ -122,8 +122,12 @@ int mbedtls_x509_string_to_names(mbedtls_asn1_named_data **head, const char *nam
char data[MBEDTLS_X509_MAX_DN_NAME_SIZE];
char *d = data;
/* Clear existing chain if present */
mbedtls_asn1_free_named_data_list(head);
/* Ensure the output parameter is not already populated.
* (If it were, overwriting it would likely cause a memory leak.)
*/
if (*head != NULL) {
return MBEDTLS_ERR_X509_BAD_INPUT_DATA;
}
while (c <= end) {
if (in_tag && *c == '=') {