diff options
| author | Rémi Verschelde <rverschelde@gmail.com> | 2021-07-20 12:32:46 +0200 |
|---|---|---|
| committer | Rémi Verschelde <rverschelde@gmail.com> | 2021-07-20 12:32:46 +0200 |
| commit | cd7b25588b2e3e5d464b87d7391db0d8c5a3ac7a (patch) | |
| tree | 628f6ec3ed622ccdfdbf44f5abc42b861cf8a968 /thirdparty/mbedtls/library/entropy.c | |
| parent | 313c88ef39bb0935b4e9e2ed44ca5e1a1e66b431 (diff) | |
| download | redot-engine-cd7b25588b2e3e5d464b87d7391db0d8c5a3ac7a.tar.gz | |
mbedtls: Update to upstream version 2.16.11
Diffstat (limited to 'thirdparty/mbedtls/library/entropy.c')
| -rw-r--r-- | thirdparty/mbedtls/library/entropy.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/thirdparty/mbedtls/library/entropy.c b/thirdparty/mbedtls/library/entropy.c index c5f414a010..9f1a32bdc1 100644 --- a/thirdparty/mbedtls/library/entropy.c +++ b/thirdparty/mbedtls/library/entropy.c @@ -494,14 +494,20 @@ int mbedtls_entropy_update_nv_seed( mbedtls_entropy_context *ctx ) int mbedtls_entropy_write_seed_file( mbedtls_entropy_context *ctx, const char *path ) { int ret = MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR; - FILE *f; + FILE *f = NULL; unsigned char buf[MBEDTLS_ENTROPY_BLOCK_SIZE]; - if( ( f = fopen( path, "wb" ) ) == NULL ) - return( MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR ); - if( ( ret = mbedtls_entropy_func( ctx, buf, MBEDTLS_ENTROPY_BLOCK_SIZE ) ) != 0 ) + { + ret = MBEDTLS_ERR_ENTROPY_SOURCE_FAILED; + goto exit; + } + + if( ( f = fopen( path, "wb" ) ) == NULL ) + { + ret = MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR; goto exit; + } if( fwrite( buf, 1, MBEDTLS_ENTROPY_BLOCK_SIZE, f ) != MBEDTLS_ENTROPY_BLOCK_SIZE ) { @@ -514,7 +520,9 @@ int mbedtls_entropy_write_seed_file( mbedtls_entropy_context *ctx, const char *p exit: mbedtls_platform_zeroize( buf, sizeof( buf ) ); - fclose( f ); + if( f != NULL ) + fclose( f ); + return( ret ); } |
