mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-12-24 01:35:46 +00:00
Merge pull request #4493 from netfoundry/gcc11.fixes_2.x
Backport 2.x: build with gcc11
This commit is contained in:
commit
a33cb76820
|
@ -726,7 +726,7 @@ static int ecdsa_signature_to_asn1( const mbedtls_mpi *r, const mbedtls_mpi *s,
|
|||
unsigned char *sig, size_t *slen )
|
||||
{
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
unsigned char buf[MBEDTLS_ECDSA_MAX_LEN];
|
||||
unsigned char buf[MBEDTLS_ECDSA_MAX_LEN] = {0};
|
||||
unsigned char *p = buf + sizeof( buf );
|
||||
size_t len = 0;
|
||||
|
||||
|
|
|
@ -3266,8 +3266,6 @@ static void ssl_calc_finished_tls_sha256(
|
|||
|
||||
#if defined(MBEDTLS_SHA512_C) && !defined(MBEDTLS_SHA512_NO_SHA384)
|
||||
|
||||
typedef int (*finish_sha384_t)(mbedtls_sha512_context*, unsigned char*);
|
||||
|
||||
static void ssl_calc_finished_tls_sha384(
|
||||
mbedtls_ssl_context *ssl, unsigned char *buf, int from )
|
||||
{
|
||||
|
@ -3326,13 +3324,19 @@ static void ssl_calc_finished_tls_sha384(
|
|||
MBEDTLS_SSL_DEBUG_BUF( 4, "finished sha512 state", (unsigned char *)
|
||||
sha512.state, sizeof( sha512.state ) );
|
||||
#endif
|
||||
/*
|
||||
* For SHA-384, we can save 16 bytes by keeping padbuf 48 bytes long.
|
||||
* However, to avoid stringop-overflow warning in gcc, we have to cast
|
||||
* mbedtls_sha512_finish_ret().
|
||||
/* mbedtls_sha512_finish_ret's output parameter is declared as a
|
||||
* 64-byte buffer, but sice we're using SHA-384, we know that the
|
||||
* output fits in 48 bytes. This is correct C, but GCC 11.1 warns
|
||||
* about it.
|
||||
*/
|
||||
finish_sha384_t finish = (finish_sha384_t)mbedtls_sha512_finish_ret;
|
||||
finish( &sha512, padbuf );
|
||||
#if defined(__GNUC__) && __GNUC__ >= 11
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wstringop-overflow"
|
||||
#endif
|
||||
mbedtls_sha512_finish_ret( &sha512, padbuf );
|
||||
#if defined(__GNUC__) && __GNUC__ >= 11
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
mbedtls_sha512_free( &sha512 );
|
||||
#endif
|
||||
|
|
|
@ -233,7 +233,7 @@ int mbedtls_x509write_crt_set_authority_key_identifier( mbedtls_x509write_cert *
|
|||
int mbedtls_x509write_crt_set_key_usage( mbedtls_x509write_cert *ctx,
|
||||
unsigned int key_usage )
|
||||
{
|
||||
unsigned char buf[5], ku[2];
|
||||
unsigned char buf[5] = {0}, ku[2] = {0};
|
||||
unsigned char *c;
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
const unsigned int allowed_bits = MBEDTLS_X509_KU_DIGITAL_SIGNATURE |
|
||||
|
@ -272,7 +272,7 @@ int mbedtls_x509write_crt_set_key_usage( mbedtls_x509write_cert *ctx,
|
|||
int mbedtls_x509write_crt_set_ns_cert_type( mbedtls_x509write_cert *ctx,
|
||||
unsigned char ns_cert_type )
|
||||
{
|
||||
unsigned char buf[4];
|
||||
unsigned char buf[4] = {0};
|
||||
unsigned char *c;
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ int mbedtls_x509write_csr_set_extension( mbedtls_x509write_csr *ctx,
|
|||
|
||||
int mbedtls_x509write_csr_set_key_usage( mbedtls_x509write_csr *ctx, unsigned char key_usage )
|
||||
{
|
||||
unsigned char buf[4];
|
||||
unsigned char buf[4] = {0};
|
||||
unsigned char *c;
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
|
||||
|
@ -113,7 +113,7 @@ int mbedtls_x509write_csr_set_key_usage( mbedtls_x509write_csr *ctx, unsigned ch
|
|||
int mbedtls_x509write_csr_set_ns_cert_type( mbedtls_x509write_csr *ctx,
|
||||
unsigned char ns_cert_type )
|
||||
{
|
||||
unsigned char buf[4];
|
||||
unsigned char buf[4] = {0};
|
||||
unsigned char *c;
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
|
||||
|
|
|
@ -1005,8 +1005,8 @@ exit:
|
|||
|
||||
for( delay_idx = 0; delay_idx < MAX_DELAYED_HS; delay_idx++ )
|
||||
{
|
||||
mbedtls_free( opt.delay_cli + delay_idx );
|
||||
mbedtls_free( opt.delay_srv + delay_idx );
|
||||
mbedtls_free( opt.delay_cli[delay_idx] );
|
||||
mbedtls_free( opt.delay_srv[delay_idx] );
|
||||
}
|
||||
|
||||
mbedtls_net_free( &client_fd );
|
||||
|
|
|
@ -2662,7 +2662,7 @@ exit:
|
|||
void ssl_message_mock_uninitialized( )
|
||||
{
|
||||
enum { MSGLEN = 10 };
|
||||
unsigned char message[MSGLEN], received[MSGLEN];
|
||||
unsigned char message[MSGLEN] = {0}, received[MSGLEN];
|
||||
mbedtls_mock_socket client, server;
|
||||
mbedtls_test_message_queue server_queue, client_queue;
|
||||
mbedtls_test_message_socket_context server_context, client_context;
|
||||
|
|
Loading…
Reference in a new issue