From 5bc072f737c3c5515644f7477804acd05889809f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Teppo=20J=C3=A4rvelin?= Date: Thu, 9 Jan 2020 12:52:25 +0200 Subject: [PATCH] Fix mbedtls_strerror to work with all wanted codes --- library/error.c | 6 +++--- scripts/data_files/error.fmt | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/library/error.c b/library/error.c index 74c9d0b39..ecdec785b 100644 --- a/library/error.c +++ b/library/error.c @@ -224,9 +224,9 @@ void mbedtls_strerror( int ret, char *buf, size_t buflen ) if( ret < 0 ) ret = -ret; - if( ret & 0xFF80 ) + if( ret & 0xFFFF80 ) { - use_ret = ret & 0xFF80; + use_ret = ret & 0xFFFF80; // High level error codes // @@ -580,7 +580,7 @@ void mbedtls_strerror( int ret, char *buf, size_t buflen ) mbedtls_snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret ); } - use_ret = ret & ~0xFF80; + use_ret = ret & ~0xFFFF80; if( use_ret == 0 ) return; diff --git a/scripts/data_files/error.fmt b/scripts/data_files/error.fmt index 4be2d85d0..2e2a5b394 100644 --- a/scripts/data_files/error.fmt +++ b/scripts/data_files/error.fmt @@ -57,9 +57,9 @@ void mbedtls_strerror( int ret, char *buf, size_t buflen ) if( ret < 0 ) ret = -ret; - if( ret & 0xFF80 ) + if( ret & 0xFFFF80 ) { - use_ret = ret & 0xFF80; + use_ret = ret & 0xFFFF80; // High level error codes // @@ -71,7 +71,7 @@ HIGH_LEVEL_CODE_CHECKS mbedtls_snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret ); } - use_ret = ret & ~0xFF80; + use_ret = ret & ~0xFFFF80; if( use_ret == 0 ) return;