From: Antonio Quartulli Date: Sun, 10 Nov 2019 13:35:24 +0000 (+0100) Subject: auth.c: make cast explicit in the crypto API X-Git-Tag: v2.5_beta1~240 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6c7b41c6536b221b1e2bc26a26ae6814a71d69e8;p=thirdparty%2Fopenvpn.git auth.c: make cast explicit in the crypto API mbedtls_md_get_size() returns unsigned char, while EVP_MD_size() returns int. Results coming from both functions are normally in a uint8_t member of the key_type struct, because it is known that 8bits are enough (also for EVP_MD_size()). This unexpected cast can, however, trigger unsolicited warnings. Make the cast explicit by changing the return value of our crypto API. Reported-by: Arne Schwabe Signed-off-by: Antonio Quartulli Acked-by: Arne Schwabe Message-Id: <20191110133525.6069-2-a@unstable.cc> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg19093.html Signed-off-by: Gert Doering --- diff --git a/src/openvpn/crypto_backend.h b/src/openvpn/crypto_backend.h index d119442f0..1d206a8ce 100644 --- a/src/openvpn/crypto_backend.h +++ b/src/openvpn/crypto_backend.h @@ -526,7 +526,7 @@ const char *md_kt_name(const md_kt_t *kt); * * @return Message digest size, in bytes, or 0 if ctx was NULL. */ -int md_kt_size(const md_kt_t *kt); +unsigned char md_kt_size(const md_kt_t *kt); /* diff --git a/src/openvpn/crypto_mbedtls.c b/src/openvpn/crypto_mbedtls.c index 648a988e8..3e77fa9ee 100644 --- a/src/openvpn/crypto_mbedtls.c +++ b/src/openvpn/crypto_mbedtls.c @@ -823,7 +823,7 @@ md_kt_name(const mbedtls_md_info_t *kt) return mbedtls_md_get_name(kt); } -int +unsigned char md_kt_size(const mbedtls_md_info_t *kt) { if (NULL == kt) diff --git a/src/openvpn/crypto_openssl.c b/src/openvpn/crypto_openssl.c index 520e40ee3..a81dcfd82 100644 --- a/src/openvpn/crypto_openssl.c +++ b/src/openvpn/crypto_openssl.c @@ -930,10 +930,10 @@ md_kt_name(const EVP_MD *kt) return EVP_MD_name(kt); } -int +unsigned char md_kt_size(const EVP_MD *kt) { - return EVP_MD_size(kt); + return (unsigned char)EVP_MD_size(kt); }