From: Max Fillinger <[email protected]>

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
---

This change was reviewed on Gerrit and approved by at least one
developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2389
This mail reflects revision 1 of this Change.

Acked-by according to Gerrit (reflected above):
Razvan Cojocaru <[email protected]>

        
diff --git a/src/openvpn/ssl_verify_openssl.c b/src/openvpn/ssl_verify_openssl.c
index ee29691..ab3c872 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);


_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to