mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-03-28 08:37:25 +00:00
Don't call memcpy(NULL, 0) which has undefined behavior
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
parent
6194053feb
commit
5969a4b5e0
@ -417,9 +417,12 @@ void test_asn1_write_bitstrings( data_t *bitstring, int bits,
|
|||||||
|
|
||||||
#if defined(MBEDTLS_ASN1_PARSE_C)
|
#if defined(MBEDTLS_ASN1_PARSE_C)
|
||||||
ASSERT_ALLOC( masked_bitstring, byte_length );
|
ASSERT_ALLOC( masked_bitstring, byte_length );
|
||||||
memcpy( masked_bitstring, bitstring->x, byte_length );
|
if( byte_length != 0 )
|
||||||
if( bits % 8 != 0 )
|
{
|
||||||
masked_bitstring[byte_length - 1] &= ~( 0xff >> ( bits % 8 ) );
|
memcpy( masked_bitstring, bitstring->x, byte_length );
|
||||||
|
if( bits % 8 != 0 )
|
||||||
|
masked_bitstring[byte_length - 1] &= ~( 0xff >> ( bits % 8 ) );
|
||||||
|
}
|
||||||
size_t value_bits = bits;
|
size_t value_bits = bits;
|
||||||
if( is_named )
|
if( is_named )
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user