[Openvpn-devel,2/3] auth.c: make cast explicit in the crypto API
Commit Message
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 <arne@rfc2549.org>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
---
src/openvpn/crypto_backend.h | 2 +-
src/openvpn/crypto_mbedtls.c | 2 +-
src/openvpn/crypto_openssl.c | 4 ++--
3 files changed, 4 insertions(+), 4 deletions(-)
Comments
Am 10.11.19 um 14:35 schrieb Antonio Quartulli:
> 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.
>
Not sure that this really needed but it also does not hurt, so
Acked-By: Arne Schwabe <arne@rfc2549.org>
Arne
Your patch has been applied to the master branch.
commit 7122af670d58586d9806214c81d27c424b226730
Author: Antonio Quartulli
Date: Sun Nov 10 14:35:24 2019 +0100
auth.c: make cast explicit in the crypto API
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
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 <gert@greenie.muc.de>
--
kind regards,
Gert Doering
Your patch has been applied to the master branch.
(Resending with correct "Acked-by" line - I noticed after I sent the mail
but before pushing, so I amended the commit and here's the right ID)
commit 6c7b41c6536b221b1e2bc26a26ae6814a71d69e8
Author: Antonio Quartulli
Date: Sun Nov 10 14:35:24 2019 +0100
auth.c: make cast explicit in the crypto API
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Arne Schwabe <arne@rfc2549.org>
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 <gert@greenie.muc.de>
--
kind regards,
Gert Doering
Your patch has been applied to the master branch.
(Resending with correct "Acked-by" line - I noticed after I sent the mail
but before pushing, so I amended the commit and here's the right ID)
commit 6c7b41c6536b221b1e2bc26a26ae6814a71d69e8
Author: Antonio Quartulli
Date: Sun Nov 10 14:35:24 2019 +0100
auth.c: make cast explicit in the crypto API
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Arne Schwabe <arne@rfc2549.org>
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 <gert@greenie.muc.de>
--
kind regards,
Gert Doering
@@ -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);
/*
@@ -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)
@@ -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);
}