mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-02-02 10:41:05 +00:00
Updated merged pk.c and x509parse.c changes with new memory allocation functions
This commit is contained in:
parent
dbd79ca617
commit
d9ca94a677
11
library/pk.c
11
library/pk.c
|
@ -37,6 +37,13 @@
|
||||||
#include "polarssl/ecdsa.h"
|
#include "polarssl/ecdsa.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(POLARSSL_MEMORY_C)
|
||||||
|
#include "polarssl/memory.h"
|
||||||
|
#else
|
||||||
|
#define polarssl_malloc malloc
|
||||||
|
#define polarssl_free free
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -80,7 +87,7 @@ void pk_free( pk_context *ctx )
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ! ctx->dont_free )
|
if( ! ctx->dont_free )
|
||||||
free( ctx->data );
|
polarssl_free( ctx->data );
|
||||||
|
|
||||||
ctx->type = POLARSSL_PK_NONE;
|
ctx->type = POLARSSL_PK_NONE;
|
||||||
ctx->data = NULL;
|
ctx->data = NULL;
|
||||||
|
@ -116,7 +123,7 @@ int pk_set_type( pk_context *ctx, pk_type_t type )
|
||||||
#endif
|
#endif
|
||||||
return( POLARSSL_ERR_PK_TYPE_MISMATCH );
|
return( POLARSSL_ERR_PK_TYPE_MISMATCH );
|
||||||
|
|
||||||
if( ( ctx->data = malloc( size ) ) == NULL )
|
if( ( ctx->data = polarssl_malloc( size ) ) == NULL )
|
||||||
return( POLARSSL_ERR_PK_MALLOC_FAILED );
|
return( POLARSSL_ERR_PK_MALLOC_FAILED );
|
||||||
|
|
||||||
memset( ctx->data, 0, size );
|
memset( ctx->data, 0, size );
|
||||||
|
|
|
@ -2091,7 +2091,7 @@ int x509parse_keyfile( pk_context *ctx,
|
||||||
(const unsigned char *) pwd, strlen( pwd ) );
|
(const unsigned char *) pwd, strlen( pwd ) );
|
||||||
|
|
||||||
memset( buf, 0, n + 1 );
|
memset( buf, 0, n + 1 );
|
||||||
free( buf );
|
polarssl_free( buf );
|
||||||
|
|
||||||
return( ret );
|
return( ret );
|
||||||
}
|
}
|
||||||
|
@ -2111,7 +2111,7 @@ int x509parse_public_keyfile( pk_context *ctx, const char *path )
|
||||||
ret = x509parse_public_key( ctx, buf, n );
|
ret = x509parse_public_key( ctx, buf, n );
|
||||||
|
|
||||||
memset( buf, 0, n + 1 );
|
memset( buf, 0, n + 1 );
|
||||||
free( buf );
|
polarssl_free( buf );
|
||||||
|
|
||||||
return( ret );
|
return( ret );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue