Ensure non-NULL key buffer when building SSL test transforms
This commit is contained in:
parent
a5780f1993
commit
78d1f70ab6
1 changed files with 5 additions and 2 deletions
|
@ -41,8 +41,11 @@ static int build_transforms( mbedtls_ssl_transform *t_in,
|
||||||
|
|
||||||
/* Pick keys */
|
/* Pick keys */
|
||||||
keylen = cipher_info->key_bitlen / 8;
|
keylen = cipher_info->key_bitlen / 8;
|
||||||
CHK( ( key0 = mbedtls_calloc( 1, keylen ) ) != NULL );
|
/* Allocate `keylen + 1` bytes to ensure that we get
|
||||||
CHK( ( key1 = mbedtls_calloc( 1, keylen ) ) != NULL );
|
* a non-NULL pointers from `mbedtls_calloc` even if
|
||||||
|
* `keylen == 0` in the case of the NULL cipher. */
|
||||||
|
CHK( ( key0 = mbedtls_calloc( 1, keylen + 1 ) ) != NULL );
|
||||||
|
CHK( ( key1 = mbedtls_calloc( 1, keylen + 1 ) ) != NULL );
|
||||||
memset( key0, 0x1, keylen );
|
memset( key0, 0x1, keylen );
|
||||||
memset( key1, 0x2, keylen );
|
memset( key1, 0x2, keylen );
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue