mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2026-04-08 21:37:20 +02:00
inet_pton: help ASan find the underflow
The generated unit tests have the input parameters in large stack buffers and therefore ASan doesn't notice under or overflows in them. Copy the input parameter into a locally allocated buffer to trigger ASan if something goes wrong. Signed-off-by: Janos Follath <janos.follath@arm.com>
This commit is contained in:
@@ -488,12 +488,22 @@ exit:
|
||||
void x509_crt_parse_cn_inet_pton(const char *cn, data_t *exp, int ref_ret)
|
||||
{
|
||||
uint32_t addr[4];
|
||||
size_t addrlen = mbedtls_x509_crt_parse_cn_inet_pton(cn, addr);
|
||||
|
||||
char *cn_local = NULL;
|
||||
size_t cn_local_len = strlen(cn) + 1;
|
||||
TEST_CALLOC(cn_local, cn_local_len);
|
||||
memcpy(cn_local, cn, cn_local_len);
|
||||
|
||||
size_t addrlen = mbedtls_x509_crt_parse_cn_inet_pton(cn_local, addr);
|
||||
TEST_EQUAL(addrlen, (size_t) ref_ret);
|
||||
|
||||
if (addrlen) {
|
||||
TEST_MEMORY_COMPARE(exp->x, exp->len, addr, addrlen);
|
||||
}
|
||||
|
||||
exit:
|
||||
mbedtls_free(cn_local);
|
||||
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user