mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
Fix integer overflow with an input buffer larger than INT_MAX
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
@ -208,7 +208,7 @@ static int parse_attribute_value_string(const char *s,
|
|||||||
* contains a null byte.
|
* contains a null byte.
|
||||||
*/
|
*/
|
||||||
static int parse_attribute_value_hex_der_encoded(const char *s,
|
static int parse_attribute_value_hex_der_encoded(const char *s,
|
||||||
int len,
|
size_t len,
|
||||||
unsigned char *data,
|
unsigned char *data,
|
||||||
size_t *data_len,
|
size_t *data_len,
|
||||||
int *tag)
|
int *tag)
|
||||||
@ -308,10 +308,12 @@ int mbedtls_x509_string_to_names(mbedtls_asn1_named_data **head, const char *nam
|
|||||||
mbedtls_free(oid.p);
|
mbedtls_free(oid.p);
|
||||||
return MBEDTLS_ERR_X509_INVALID_NAME;
|
return MBEDTLS_ERR_X509_INVALID_NAME;
|
||||||
} else if (*s == '#') {
|
} else if (*s == '#') {
|
||||||
if ((parse_ret =
|
/* We know that c >= s (loop invariant) and c != s (in this
|
||||||
parse_attribute_value_hex_der_encoded(s + 1, (int) (c - s - 1),
|
* else branch), hence c - s - 1 >= 0. */
|
||||||
data, &data_len,
|
parse_ret = parse_attribute_value_hex_der_encoded(
|
||||||
&tag)) != 0) {
|
s + 1, c - s - 1,
|
||||||
|
data, &data_len, &tag);
|
||||||
|
if (parse_ret != 0) {
|
||||||
mbedtls_free(oid.p);
|
mbedtls_free(oid.p);
|
||||||
return MBEDTLS_ERR_X509_INVALID_NAME;
|
return MBEDTLS_ERR_X509_INVALID_NAME;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user