mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2026-10-28 18:07:34 +08:00
Rely on Asan in cookie_write_bounds instead of guard bytes
Signed-off-by: Naveed <naveed@bugqore.com>
This commit is contained in:
parent
258bbbbdb0
commit
8dcfe327b7
@ -4302,16 +4302,15 @@ void cookie_write_bounds(int out_len, int exp_ret)
|
||||
{
|
||||
mbedtls_ssl_cookie_ctx ctx;
|
||||
const unsigned char cli_id[] = { 0x7f, 0x00, 0x00, 0x01, 0x12, 0x34 };
|
||||
const size_t guard_len = 64;
|
||||
unsigned char *buf = NULL;
|
||||
unsigned char *p;
|
||||
size_t i;
|
||||
|
||||
mbedtls_ssl_cookie_init(&ctx);
|
||||
PSA_INIT();
|
||||
|
||||
TEST_CALLOC(buf, out_len + guard_len);
|
||||
memset(buf, 0x5a, out_len + guard_len);
|
||||
/* Allocate exactly out_len bytes so that Asan catches any write past
|
||||
* the end of the output buffer. */
|
||||
TEST_CALLOC(buf, out_len);
|
||||
|
||||
TEST_EQUAL(mbedtls_ssl_cookie_setup(&ctx), 0);
|
||||
|
||||
@ -4319,11 +4318,6 @@ void cookie_write_bounds(int out_len, int exp_ret)
|
||||
TEST_EQUAL(mbedtls_ssl_cookie_write(&ctx, &p, buf + out_len,
|
||||
cli_id, sizeof(cli_id)), exp_ret);
|
||||
|
||||
/* Nothing may be written past the end of the output buffer */
|
||||
for (i = out_len; i < out_len + guard_len; i++) {
|
||||
TEST_EQUAL(buf[i], 0x5a);
|
||||
}
|
||||
|
||||
if (exp_ret == 0) {
|
||||
TEST_EQUAL(p - buf, out_len);
|
||||
TEST_EQUAL(mbedtls_ssl_cookie_check(&ctx, buf, p - buf,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user