From 69c303360e11b5946d8665fb1aa0f1a0c4eba232 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Fri, 28 Jun 2019 15:47:53 +0100 Subject: [PATCH] Don't return threading error on release()-without-acquire() calls Previously, a call to mbedtls_x509_crt_xxx_release() would return MBEDTLS_ERR_THREADING_MUTEX_ERROR if usage counter for the frame/PK was 0. Now that resource counting can also be used outside of threading support, this is no longer adequate, and this commit changes the return code to MBEDTLS_ERR_X509_FATAL_ERROR; while generic, this at least matches the top-level module. --- include/mbedtls/x509_crt.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/mbedtls/x509_crt.h b/include/mbedtls/x509_crt.h index 692bfe4f2..3eee460fb 100644 --- a/include/mbedtls/x509_crt.h +++ b/include/mbedtls/x509_crt.h @@ -878,7 +878,7 @@ static inline int mbedtls_x509_crt_frame_release( mbedtls_x509_crt const *crt ) #if !defined(MBEDTLS_X509_ALWAYS_FLUSH) || \ defined(MBEDTLS_THREADING_C) if( crt->cache->frame_readers == 0 ) - return( MBEDTLS_ERR_THREADING_MUTEX_ERROR ); + return( MBEDTLS_ERR_X509_FATAL_ERROR ); crt->cache->frame_readers--; #endif @@ -980,7 +980,7 @@ static inline int mbedtls_x509_crt_pk_release( mbedtls_x509_crt const *crt ) #if !defined(MBEDTLS_X509_ALWAYS_FLUSH) || \ defined(MBEDTLS_THREADING_C) if( crt->cache->pk_readers == 0 ) - return( MBEDTLS_ERR_THREADING_MUTEX_ERROR ); + return( MBEDTLS_ERR_X509_FATAL_ERROR ); crt->cache->pk_readers--; #endif