Rename ERR_xxx_MALLOC_FAILED to ..._ALLOC_FAILED
diff --git a/library/asn1parse.c b/library/asn1parse.c
index 563e9a7..e2c0702 100644
--- a/library/asn1parse.c
+++ b/library/asn1parse.c
@@ -273,7 +273,7 @@
cur->next = mbedtls_calloc( 1, sizeof( mbedtls_asn1_sequence ) );
if( cur->next == NULL )
- return( MBEDTLS_ERR_ASN1_MALLOC_FAILED );
+ return( MBEDTLS_ERR_ASN1_ALLOC_FAILED );
cur = cur->next;
}
diff --git a/library/bignum.c b/library/bignum.c
index b65858d..f94bf57 100644
--- a/library/bignum.c
+++ b/library/bignum.c
@@ -105,12 +105,12 @@
mbedtls_mpi_uint *p;
if( nblimbs > MBEDTLS_MPI_MAX_LIMBS )
- return( MBEDTLS_ERR_MPI_MALLOC_FAILED );
+ return( MBEDTLS_ERR_MPI_ALLOC_FAILED );
if( X->n < nblimbs )
{
if( ( p = mbedtls_calloc( nblimbs, ciL ) ) == NULL )
- return( MBEDTLS_ERR_MPI_MALLOC_FAILED );
+ return( MBEDTLS_ERR_MPI_ALLOC_FAILED );
if( X->p != NULL )
{
@@ -148,7 +148,7 @@
i = nblimbs;
if( ( p = mbedtls_calloc( i, ciL ) ) == NULL )
- return( MBEDTLS_ERR_MPI_MALLOC_FAILED );
+ return( MBEDTLS_ERR_MPI_ALLOC_FAILED );
if( X->p != NULL )
{
diff --git a/library/dhm.c b/library/dhm.c
index af70885..6b4e29f 100644
--- a/library/dhm.c
+++ b/library/dhm.c
@@ -534,7 +534,7 @@
( *buf = mbedtls_calloc( 1, *n + 1 ) ) == NULL )
{
fclose( f );
- return( MBEDTLS_ERR_DHM_MALLOC_FAILED );
+ return( MBEDTLS_ERR_DHM_ALLOC_FAILED );
}
if( fread( *buf, 1, *n, f ) != *n )
diff --git a/library/ecp.c b/library/ecp.c
index 37c2472..8f289f0 100644
--- a/library/ecp.c
+++ b/library/ecp.c
@@ -791,7 +791,7 @@
return( ecp_normalize_jac( grp, *T ) );
if( ( c = mbedtls_calloc( t_len, sizeof( mbedtls_mpi ) ) ) == NULL )
- return( MBEDTLS_ERR_ECP_MALLOC_FAILED );
+ return( MBEDTLS_ERR_ECP_ALLOC_FAILED );
mbedtls_mpi_init( &u ); mbedtls_mpi_init( &Zi ); mbedtls_mpi_init( &ZZi );
@@ -1364,7 +1364,7 @@
T = mbedtls_calloc( pre_len, sizeof( mbedtls_ecp_point ) );
if( T == NULL )
{
- ret = MBEDTLS_ERR_ECP_MALLOC_FAILED;
+ ret = MBEDTLS_ERR_ECP_ALLOC_FAILED;
goto cleanup;
}
diff --git a/library/error.c b/library/error.c
index 2775a40..c9e5e79 100644
--- a/library/error.c
+++ b/library/error.c
@@ -234,7 +234,7 @@
mbedtls_snprintf( buf, buflen, "DHM - Calculation of the DHM secret failed" );
if( use_ret == -(MBEDTLS_ERR_DHM_INVALID_FORMAT) )
mbedtls_snprintf( buf, buflen, "DHM - The ASN.1 data is not formatted correctly" );
- if( use_ret == -(MBEDTLS_ERR_DHM_MALLOC_FAILED) )
+ if( use_ret == -(MBEDTLS_ERR_DHM_ALLOC_FAILED) )
mbedtls_snprintf( buf, buflen, "DHM - Allocation of memory failed" );
if( use_ret == -(MBEDTLS_ERR_DHM_FILE_IO_ERROR) )
mbedtls_snprintf( buf, buflen, "DHM - Read/write of file failed" );
@@ -249,7 +249,7 @@
mbedtls_snprintf( buf, buflen, "ECP - Requested curve not available" );
if( use_ret == -(MBEDTLS_ERR_ECP_VERIFY_FAILED) )
mbedtls_snprintf( buf, buflen, "ECP - The signature is not valid" );
- if( use_ret == -(MBEDTLS_ERR_ECP_MALLOC_FAILED) )
+ if( use_ret == -(MBEDTLS_ERR_ECP_ALLOC_FAILED) )
mbedtls_snprintf( buf, buflen, "ECP - Memory allocation failed" );
if( use_ret == -(MBEDTLS_ERR_ECP_RANDOM_FAILED) )
mbedtls_snprintf( buf, buflen, "ECP - Generation of random value, such as (ephemeral) key, failed" );
@@ -275,7 +275,7 @@
mbedtls_snprintf( buf, buflen, "PEM - No PEM header or footer found" );
if( use_ret == -(MBEDTLS_ERR_PEM_INVALID_DATA) )
mbedtls_snprintf( buf, buflen, "PEM - PEM string is not as expected" );
- if( use_ret == -(MBEDTLS_ERR_PEM_MALLOC_FAILED) )
+ if( use_ret == -(MBEDTLS_ERR_PEM_ALLOC_FAILED) )
mbedtls_snprintf( buf, buflen, "PEM - Failed to allocate memory" );
if( use_ret == -(MBEDTLS_ERR_PEM_INVALID_ENC_IV) )
mbedtls_snprintf( buf, buflen, "PEM - RSA IV is not in hex-format" );
@@ -292,7 +292,7 @@
#endif /* MBEDTLS_PEM_PARSE_C || MBEDTLS_PEM_WRITE_C */
#if defined(MBEDTLS_PK_C)
- if( use_ret == -(MBEDTLS_ERR_PK_MALLOC_FAILED) )
+ if( use_ret == -(MBEDTLS_ERR_PK_ALLOC_FAILED) )
mbedtls_snprintf( buf, buflen, "PK - Memory alloation failed" );
if( use_ret == -(MBEDTLS_ERR_PK_TYPE_MISMATCH) )
mbedtls_snprintf( buf, buflen, "PK - Type mismatch, eg attempt to encrypt with an ECDSA key" );
@@ -427,7 +427,7 @@
mbedtls_snprintf( buf, buflen, "SSL - Processing of the ChangeCipherSpec handshake message failed" );
if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_FINISHED) )
mbedtls_snprintf( buf, buflen, "SSL - Processing of the Finished handshake message failed" );
- if( use_ret == -(MBEDTLS_ERR_SSL_MALLOC_FAILED) )
+ if( use_ret == -(MBEDTLS_ERR_SSL_ALLOC_FAILED) )
mbedtls_snprintf( buf, buflen, "SSL - Memory allocation failed" );
if( use_ret == -(MBEDTLS_ERR_SSL_HW_ACCEL_FAILED) )
mbedtls_snprintf( buf, buflen, "SSL - Hardware acceleration function returned with error" );
@@ -498,7 +498,7 @@
mbedtls_snprintf( buf, buflen, "X509 - Format not recognized as DER or PEM" );
if( use_ret == -(MBEDTLS_ERR_X509_BAD_INPUT_DATA) )
mbedtls_snprintf( buf, buflen, "X509 - Input invalid" );
- if( use_ret == -(MBEDTLS_ERR_X509_MALLOC_FAILED) )
+ if( use_ret == -(MBEDTLS_ERR_X509_ALLOC_FAILED) )
mbedtls_snprintf( buf, buflen, "X509 - Allocation of memory failed" );
if( use_ret == -(MBEDTLS_ERR_X509_FILE_IO_ERROR) )
mbedtls_snprintf( buf, buflen, "X509 - Read/write of file failed" );
@@ -551,7 +551,7 @@
mbedtls_snprintf( buf, buflen, "ASN1 - Actual length differs from expected length" );
if( use_ret == -(MBEDTLS_ERR_ASN1_INVALID_DATA) )
mbedtls_snprintf( buf, buflen, "ASN1 - Data is invalid. (not used)" );
- if( use_ret == -(MBEDTLS_ERR_ASN1_MALLOC_FAILED) )
+ if( use_ret == -(MBEDTLS_ERR_ASN1_ALLOC_FAILED) )
mbedtls_snprintf( buf, buflen, "ASN1 - Memory allocation failed" );
if( use_ret == -(MBEDTLS_ERR_ASN1_BUF_TOO_SMALL) )
mbedtls_snprintf( buf, buflen, "ASN1 - Buffer too small when writing ASN.1 data structure" );
@@ -579,7 +579,7 @@
mbedtls_snprintf( buf, buflen, "BIGNUM - The input argument for division is zero, which is not allowed" );
if( use_ret == -(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE) )
mbedtls_snprintf( buf, buflen, "BIGNUM - The input arguments are not acceptable" );
- if( use_ret == -(MBEDTLS_ERR_MPI_MALLOC_FAILED) )
+ if( use_ret == -(MBEDTLS_ERR_MPI_ALLOC_FAILED) )
mbedtls_snprintf( buf, buflen, "BIGNUM - Memory allocation failed" );
#endif /* MBEDTLS_BIGNUM_C */
diff --git a/library/pem.c b/library/pem.c
index ed6747a..c1561cb 100644
--- a/library/pem.c
+++ b/library/pem.c
@@ -322,7 +322,7 @@
return( MBEDTLS_ERR_PEM_INVALID_DATA + ret );
if( ( buf = mbedtls_calloc( 1, len ) ) == NULL )
- return( MBEDTLS_ERR_PEM_MALLOC_FAILED );
+ return( MBEDTLS_ERR_PEM_ALLOC_FAILED );
if( ( ret = mbedtls_base64_decode( buf, &len, s1, s2 - s1 ) ) != 0 )
{
@@ -408,7 +408,7 @@
}
if( ( encode_buf = mbedtls_calloc( 1, use_len ) ) == NULL )
- return( MBEDTLS_ERR_PEM_MALLOC_FAILED );
+ return( MBEDTLS_ERR_PEM_ALLOC_FAILED );
if( ( ret = mbedtls_base64_encode( encode_buf, &use_len, der_data,
der_len ) ) != 0 )
diff --git a/library/pk.c b/library/pk.c
index 9da2b77..464243e 100644
--- a/library/pk.c
+++ b/library/pk.c
@@ -105,7 +105,7 @@
return( MBEDTLS_ERR_PK_BAD_INPUT_DATA );
if( ( ctx->pk_ctx = info->ctx_alloc_func() ) == NULL )
- return( MBEDTLS_ERR_PK_MALLOC_FAILED );
+ return( MBEDTLS_ERR_PK_ALLOC_FAILED );
ctx->pk_info = info;
@@ -128,7 +128,7 @@
return( MBEDTLS_ERR_PK_BAD_INPUT_DATA );
if( ( ctx->pk_ctx = info->ctx_alloc_func() ) == NULL )
- return( MBEDTLS_ERR_PK_MALLOC_FAILED );
+ return( MBEDTLS_ERR_PK_ALLOC_FAILED );
ctx->pk_info = info;
diff --git a/library/pkparse.c b/library/pkparse.c
index 254a04d..c8a68eb 100644
--- a/library/pkparse.c
+++ b/library/pkparse.c
@@ -96,7 +96,7 @@
( *buf = mbedtls_calloc( 1, *n + 1 ) ) == NULL )
{
fclose( f );
- return( MBEDTLS_ERR_PK_MALLOC_FAILED );
+ return( MBEDTLS_ERR_PK_ALLOC_FAILED );
}
if( fread( *buf, 1, *n, f ) != *n )
diff --git a/library/ssl_cli.c b/library/ssl_cli.c
index ec2b346..cff8871 100644
--- a/library/ssl_cli.c
+++ b/library/ssl_cli.c
@@ -1155,7 +1155,7 @@
if( ssl->handshake->verify_cookie == NULL )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "alloc failed (%d bytes)", cookie_len ) );
- return( MBEDTLS_ERR_SSL_MALLOC_FAILED );
+ return( MBEDTLS_ERR_SSL_ALLOC_FAILED );
}
memcpy( ssl->handshake->verify_cookie, p, cookie_len );
@@ -2914,7 +2914,7 @@
if( ( ticket = mbedtls_calloc( 1, ticket_len ) ) == NULL )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "ticket alloc failed" ) );
- return( MBEDTLS_ERR_SSL_MALLOC_FAILED );
+ return( MBEDTLS_ERR_SSL_ALLOC_FAILED );
}
memcpy( ticket, msg + 6, ticket_len );
diff --git a/library/ssl_srv.c b/library/ssl_srv.c
index d2b585b..72f9eee 100644
--- a/library/ssl_srv.c
+++ b/library/ssl_srv.c
@@ -68,7 +68,7 @@
mbedtls_free( ssl->cli_id );
if( ( ssl->cli_id = mbedtls_calloc( 1, ilen ) ) == NULL )
- return( MBEDTLS_ERR_SSL_MALLOC_FAILED );
+ return( MBEDTLS_ERR_SSL_ALLOC_FAILED );
memcpy( ssl->cli_id, info, ilen );
ssl->cli_id_len = ilen;
@@ -264,7 +264,7 @@
our_size = MBEDTLS_ECP_DP_MAX;
if( ( curves = mbedtls_calloc( our_size, sizeof( *curves ) ) ) == NULL )
- return( MBEDTLS_ERR_SSL_MALLOC_FAILED );
+ return( MBEDTLS_ERR_SSL_ALLOC_FAILED );
ssl->handshake->curves = curves;
diff --git a/library/ssl_ticket.c b/library/ssl_ticket.c
index 7b76218..baa8b82 100644
--- a/library/ssl_ticket.c
+++ b/library/ssl_ticket.c
@@ -247,7 +247,7 @@
session->peer_cert = mbedtls_calloc( 1, sizeof( mbedtls_x509_crt ) );
if( session->peer_cert == NULL )
- return( MBEDTLS_ERR_SSL_MALLOC_FAILED );
+ return( MBEDTLS_ERR_SSL_ALLOC_FAILED );
mbedtls_x509_crt_init( session->peer_cert );
diff --git a/library/ssl_tls.c b/library/ssl_tls.c
index 76c644b..29dcf94 100644
--- a/library/ssl_tls.c
+++ b/library/ssl_tls.c
@@ -175,7 +175,7 @@
dst->peer_cert = mbedtls_calloc( 1, sizeof(mbedtls_x509_crt) );
if( dst->peer_cert == NULL )
- return( MBEDTLS_ERR_SSL_MALLOC_FAILED );
+ return( MBEDTLS_ERR_SSL_ALLOC_FAILED );
mbedtls_x509_crt_init( dst->peer_cert );
@@ -194,7 +194,7 @@
{
dst->ticket = mbedtls_calloc( 1, src->ticket_len );
if( dst->ticket == NULL )
- return( MBEDTLS_ERR_SSL_MALLOC_FAILED );
+ return( MBEDTLS_ERR_SSL_ALLOC_FAILED );
memcpy( dst->ticket, src->ticket, src->ticket_len );
}
@@ -934,7 +934,7 @@
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "alloc(%d bytes) failed",
MBEDTLS_SSL_BUFFER_LEN ) );
- return( MBEDTLS_ERR_SSL_MALLOC_FAILED );
+ return( MBEDTLS_ERR_SSL_ALLOC_FAILED );
}
}
@@ -2458,14 +2458,14 @@
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "alloc %d bytes failed",
sizeof( mbedtls_ssl_flight_item ) ) );
- return( MBEDTLS_ERR_SSL_MALLOC_FAILED );
+ return( MBEDTLS_ERR_SSL_ALLOC_FAILED );
}
if( ( msg->p = mbedtls_calloc( 1, ssl->out_msglen ) ) == NULL )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "alloc %d bytes failed", ssl->out_msglen ) );
mbedtls_free( msg );
- return( MBEDTLS_ERR_SSL_MALLOC_FAILED );
+ return( MBEDTLS_ERR_SSL_ALLOC_FAILED );
}
/* Copy current handshake message with headers */
@@ -2928,7 +2928,7 @@
if( ssl->handshake->hs_msg == NULL )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "alloc failed (%d bytes)", alloc_len ) );
- return( MBEDTLS_ERR_SSL_MALLOC_FAILED );
+ return( MBEDTLS_ERR_SSL_ALLOC_FAILED );
}
/* Prepare final header: copy msg_type, length and message_seq,
@@ -3978,7 +3978,7 @@
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "alloc(%d bytes) failed",
sizeof( mbedtls_x509_crt ) ) );
- return( MBEDTLS_ERR_SSL_MALLOC_FAILED );
+ return( MBEDTLS_ERR_SSL_ALLOC_FAILED );
}
mbedtls_x509_crt_init( ssl->session_negotiate->peer_cert );
@@ -4924,7 +4924,7 @@
ssl->transform_negotiate = NULL;
ssl->session_negotiate = NULL;
- return( MBEDTLS_ERR_SSL_MALLOC_FAILED );
+ return( MBEDTLS_ERR_SSL_ALLOC_FAILED );
}
/* Initialize structures */
@@ -5006,7 +5006,7 @@
MBEDTLS_SSL_DEBUG_MSG( 1, ( "alloc(%d bytes) failed", len ) );
mbedtls_free( ssl->in_buf );
ssl->in_buf = NULL;
- return( MBEDTLS_ERR_SSL_MALLOC_FAILED );
+ return( MBEDTLS_ERR_SSL_ALLOC_FAILED );
}
#if defined(MBEDTLS_SSL_PROTO_DTLS)
@@ -5306,7 +5306,7 @@
new = mbedtls_calloc( 1, sizeof( mbedtls_ssl_key_cert ) );
if( new == NULL )
- return( MBEDTLS_ERR_SSL_MALLOC_FAILED );
+ return( MBEDTLS_ERR_SSL_ALLOC_FAILED );
new->cert = cert;
new->key = key;
@@ -5384,7 +5384,7 @@
{
mbedtls_free( conf->psk );
conf->psk = NULL;
- return( MBEDTLS_ERR_SSL_MALLOC_FAILED );
+ return( MBEDTLS_ERR_SSL_ALLOC_FAILED );
}
conf->psk_len = psk_len;
@@ -5412,7 +5412,7 @@
{
mbedtls_free( ssl->handshake->psk );
ssl->handshake->psk = NULL;
- return( MBEDTLS_ERR_SSL_MALLOC_FAILED );
+ return( MBEDTLS_ERR_SSL_ALLOC_FAILED );
}
ssl->handshake->psk_len = psk_len;
@@ -5490,7 +5490,7 @@
ssl->hostname = mbedtls_calloc( 1, hostname_len + 1 );
if( ssl->hostname == NULL )
- return( MBEDTLS_ERR_SSL_MALLOC_FAILED );
+ return( MBEDTLS_ERR_SSL_ALLOC_FAILED );
memcpy( ssl->hostname, hostname, hostname_len );
diff --git a/library/x509.c b/library/x509.c
index 0e998fc..504fcf7 100644
--- a/library/x509.c
+++ b/library/x509.c
@@ -455,7 +455,7 @@
cur->next = mbedtls_calloc( 1, sizeof( mbedtls_x509_name ) );
if( cur->next == NULL )
- return( MBEDTLS_ERR_X509_MALLOC_FAILED );
+ return( MBEDTLS_ERR_X509_ALLOC_FAILED );
cur = cur->next;
}
@@ -469,7 +469,7 @@
cur->next = mbedtls_calloc( 1, sizeof( mbedtls_x509_name ) );
if( cur->next == NULL )
- return( MBEDTLS_ERR_X509_MALLOC_FAILED );
+ return( MBEDTLS_ERR_X509_ALLOC_FAILED );
cur = cur->next;
}
@@ -595,7 +595,7 @@
pss_opts = mbedtls_calloc( 1, sizeof( mbedtls_pk_rsassa_pss_options ) );
if( pss_opts == NULL )
- return( MBEDTLS_ERR_X509_MALLOC_FAILED );
+ return( MBEDTLS_ERR_X509_ALLOC_FAILED );
ret = mbedtls_x509_get_rsassa_pss_params( sig_params,
md_alg,
diff --git a/library/x509_create.c b/library/x509_create.c
index 9a22052..9066642 100644
--- a/library/x509_create.c
+++ b/library/x509_create.c
@@ -137,7 +137,7 @@
(unsigned char *) data,
d - data ) == NULL )
{
- return( MBEDTLS_ERR_X509_MALLOC_FAILED );
+ return( MBEDTLS_ERR_X509_ALLOC_FAILED );
}
while( c < end && *(c + 1) == ' ' )
@@ -177,7 +177,7 @@
if( ( cur = mbedtls_asn1_store_named_data( head, oid, oid_len,
NULL, val_len + 1 ) ) == NULL )
{
- return( MBEDTLS_ERR_X509_MALLOC_FAILED );
+ return( MBEDTLS_ERR_X509_ALLOC_FAILED );
}
cur->val.p[0] = critical;
diff --git a/library/x509_crl.c b/library/x509_crl.c
index 62d0a30..61b1bec 100644
--- a/library/x509_crl.c
+++ b/library/x509_crl.c
@@ -241,7 +241,7 @@
cur_entry->next = mbedtls_calloc( 1, sizeof( mbedtls_x509_crl_entry ) );
if( cur_entry->next == NULL )
- return( MBEDTLS_ERR_X509_MALLOC_FAILED );
+ return( MBEDTLS_ERR_X509_ALLOC_FAILED );
cur_entry = cur_entry->next;
}
@@ -285,7 +285,7 @@
if( crl->next == NULL )
{
mbedtls_x509_crl_free( crl );
- return( MBEDTLS_ERR_X509_MALLOC_FAILED );
+ return( MBEDTLS_ERR_X509_ALLOC_FAILED );
}
mbedtls_x509_crl_init( crl->next );
@@ -296,7 +296,7 @@
* Copy raw DER-encoded CRL
*/
if( ( p = mbedtls_calloc( 1, buflen ) ) == NULL )
- return( MBEDTLS_ERR_X509_MALLOC_FAILED );
+ return( MBEDTLS_ERR_X509_ALLOC_FAILED );
memcpy( p, buf, buflen );
diff --git a/library/x509_crt.c b/library/x509_crt.c
index e46c934..8967337 100644
--- a/library/x509_crt.c
+++ b/library/x509_crt.c
@@ -363,7 +363,7 @@
if( cur->next == NULL )
return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS +
- MBEDTLS_ERR_ASN1_MALLOC_FAILED );
+ MBEDTLS_ERR_ASN1_ALLOC_FAILED );
cur = cur->next;
}
@@ -554,7 +554,7 @@
p = mbedtls_calloc( 1, len = buflen );
if( p == NULL )
- return( MBEDTLS_ERR_X509_MALLOC_FAILED );
+ return( MBEDTLS_ERR_X509_ALLOC_FAILED );
memcpy( p, buf, buflen );
@@ -810,7 +810,7 @@
crt->next = mbedtls_calloc( 1, sizeof( mbedtls_x509_crt ) );
if( crt->next == NULL )
- return( MBEDTLS_ERR_X509_MALLOC_FAILED );
+ return( MBEDTLS_ERR_X509_ALLOC_FAILED );
prev = crt;
mbedtls_x509_crt_init( crt->next );
@@ -919,7 +919,7 @@
/*
* Quit parsing on a memory error
*/
- if( ret == MBEDTLS_ERR_X509_MALLOC_FAILED )
+ if( ret == MBEDTLS_ERR_X509_ALLOC_FAILED )
return( ret );
if( first_error == 0 )
diff --git a/library/x509_csr.c b/library/x509_csr.c
index 4347fbb..d8ed04a 100644
--- a/library/x509_csr.c
+++ b/library/x509_csr.c
@@ -116,7 +116,7 @@
p = mbedtls_calloc( 1, len = buflen );
if( p == NULL )
- return( MBEDTLS_ERR_X509_MALLOC_FAILED );
+ return( MBEDTLS_ERR_X509_ALLOC_FAILED );
memcpy( p, buf, buflen );