Gert Doering has submitted this change. ( 
https://gerrit.openvpn.net/c/openvpn/+/2389?usp=email )

Change subject: Add cast to BN_num_bytes return value for AWS-LC
......................................................................

Add cast to BN_num_bytes return value for AWS-LC

The return value of BN_num_bytes is int in OpenSSL but unsigned int in
AWS-LC. This caused a compiler warning, and causes builds with
-Werror=sign-conversion to fail. This commit casts the return value to
unsigned int.

Change-Id: I24d3e80182e4121b3d84c3bdc07d3172f872da8f
Signed-off-by: Max Fillinger <[email protected]>
Acked-by: Razvan Cojocaru <[email protected]>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2389
Message-Id: <[email protected]>
URL: 
https://lore.kernel.org/openvpn-devel/[email protected]
Signed-off-by: Gert Doering <[email protected]>
---
M src/openvpn/ssl_verify_openssl.c
1 file changed, 5 insertions(+), 1 deletion(-)




diff --git a/src/openvpn/ssl_verify_openssl.c b/src/openvpn/ssl_verify_openssl.c
index ee29691..bb5d26d 100644
--- a/src/openvpn/ssl_verify_openssl.c
+++ b/src/openvpn/ssl_verify_openssl.c
@@ -61,7 +61,11 @@
     BIGNUM *bn_serial = ASN1_INTEGER_to_BN(asn1_i, NULL);
     if (bn_serial != NULL)
     {
-        int size = BN_num_bytes(bn_serial);
+        /* Cast the return value of BN_num_bytes to unsigned int because it is
+         * int in OpenSSL and unsigned int in AWS-LC. The return value of
+         * BN_num_bytes should never be negative, and if it is, the cast will
+         * turn it into an unacceptably large value which will fail this 
check. */
+        unsigned int size = (unsigned int)BN_num_bytes(bn_serial);
         size_ok = size <= MAX_SERIAL_SIZE;
     }
     BN_free(bn_serial);

--
To view, visit https://gerrit.openvpn.net/c/openvpn/+/2389?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I24d3e80182e4121b3d84c3bdc07d3172f872da8f
Gerrit-Change-Number: 2389
Gerrit-PatchSet: 2
Gerrit-Owner: Max Fillinger <[email protected]>
Gerrit-Reviewer: Arne Schwabe <[email protected]>
Gerrit-Reviewer: Răzvan Cojocaru <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to