Change in openvpn[master]: ssl_mbedtls: Avoid conversion and sign-compare warnings
A message that is not in the archive (sent off-list or not yet received): gerrit.1772798203000.I777a3a5f4f137432a19746972e2aad1732184feb@...2715...
Attention is currently required from: plaisthos.
Hello plaisthos,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/1559?usp=email
to review the following change.
Change subject: ssl_mbedtls: Avoid conversion and sign-compare warnings
......................................................................
ssl_mbedtls: Avoid conversion and sign-compare warnings
---
M src/openvpn/ssl_mbedtls.c
M src/openvpn/ssl_verify_mbedtls.c
2 files changed, 17 insertions(+), 31 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/59/1559/1
src/openvpn/ssl_mbedtls.c +17 -22
@@ -624,12 +624,6 @@return 0 ; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#pragma GCC diagnostic ignored "-Wsign-compare" -#endif -#if MBEDTLS_VERSION_NUMBER <0x04000000 /** * external_pkcs1_sign implements a mbed TLS rsa_sign_func callback, that uses
@@ -656,7 +650,6 @@ {struct external_context *const ctx = ctx_voidptr;int rv; -uint8_t *to_sign =NULL ;size_t asn_len =0 , oid_size =0 ;const char *oid =NULL ;
@@ -688,11 +681,13 @@ asn_len =10 + oid_size; } -if ((SIZE_MAX - hashlen) < asn_len || ctx->signature_length < (asn_len + hashlen)) +if (ctx->signature_length < (asn_len + hashlen) + || (asn_len + hashlen) >UINT8_MAX ) {return MBEDTLS_ERR_RSA_BAD_INPUT_DATA ; } +uint8_t *to_sign =NULL ;ALLOC_ARRAY_CLEAR (to_sign, uint8_t, asn_len + hashlen);uint8_t *p = to_sign;if (md_alg !=MBEDTLS_MD_NONE )
@@ -707,20 +702,20 @@* Digest ::= OCTET STRING */ *p++ =MBEDTLS_ASN1_SEQUENCE |MBEDTLS_ASN1_CONSTRUCTED ; - *p++ = (unsigned char )(0x08 + oid_size + hashlen); + *p++ = (uint8_t )(0x08 + oid_size + hashlen); *p++ =MBEDTLS_ASN1_SEQUENCE |MBEDTLS_ASN1_CONSTRUCTED ; - *p++ = (unsigned char )(0x04 + oid_size); + *p++ = (uint8_t )(0x04 + oid_size); *p++ =MBEDTLS_ASN1_OID ; - *p++ = oid_size &0xFF ; + *p++ = (uint8_t )oid_size;memcpy (p, oid, oid_size); p += oid_size; *p++ =MBEDTLS_ASN1_NULL ; *p++ =0x00 ; *p++ =MBEDTLS_ASN1_OCTET_STRING ; - *p++ = hashlen; + *p++ = (uint8_t )hashlen;/* Double-check ASN length */ -ASSERT (asn_len == p - to_sign); +ASSERT (asn_len == (uintptr_t )(p - to_sign)); }/* Copy the hash to be signed */
@@ -810,7 +805,7 @@ goto cleanup; } -if (openvpn_base64_decode (dst_b64, dst, (int )dst_len) != dst_len) +if (openvpn_base64_decode (dst_b64, dst, (int )dst_len) != (int )dst_len) { goto cleanup; }
@@ -923,6 +918,8 @@ {size_t read_len =0 ; +ASSERT (out_len <=INT_MAX ); +if (in->first_block ==NULL ) {return MBEDTLS_ERR_SSL_WANT_READ ;
@@ -930,7 +927,7 @@while (in->first_block !=NULL && read_len < out_len) { -int block_len = in->first_block->length - in->data_start; +size_t block_len = in->first_block->length - in->data_start;if (block_len <= out_len - read_len) {buffer_entry *cur_entry = in->first_block;
@@ -956,7 +953,7 @@ } } -return read_len; +return (int )read_len; } static int
@@ -975,6 +972,8 @@return MBEDTLS_ERR_NET_SEND_FAILED ; } +ASSERT (len <=INT_MAX ); + new_block->length = len; new_block->next_block =NULL ;
@@ -992,7 +991,7 @@ out->last_block = new_block; -return len; +return (int )len; } static int
@@ -1012,7 +1011,7 @@static void my_debug (void *ctx,int level,const char *file,int line,const char *str) { -int my_loglevel = (level <3 ) ?D_TLS_DEBUG_MED :D_TLS_DEBUG ; +unsigned int my_loglevel = (level <3 ) ?D_TLS_DEBUG_MED :D_TLS_DEBUG ;msg (my_loglevel,"mbed TLS msg (%s:%d): %s" , file, line, str); }
@@ -1048,10 +1047,6 @@#endif /* MBEDTLS_VERSION_NUMBER < 0x040000 */ } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif -int tls_version_max (void ) {
src/openvpn/ssl_verify_mbedtls.c +0 -9
@@ -565,11 +565,6 @@gc_free (&gc); } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsign-compare" -#endif -/* * Save X509 fields to environment, using the naming convention: *
@@ -678,10 +673,6 @@return fFound; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif -result_t x509_verify_cert_eku (mbedtls_x509_crt *cert,const char *const expected_oid) {
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1559?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I777a3a5f4f137432a19746972e2aad1732184feb
Gerrit-Change-Number: 1559
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Attention is currently required from: plaisthos.
Hello plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/1559?usp=email
to look at the new patch set (#2).
Change subject: ssl_mbedtls: Avoid conversion and sign-compare warnings
......................................................................
ssl_mbedtls: Avoid conversion and sign-compare warnings
---
M src/openvpn/ssl_mbedtls.c
M src/openvpn/ssl_verify_mbedtls.c
2 files changed, 17 insertions(+), 31 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/59/1559/2
src/openvpn/ssl_mbedtls.c +17 -22
@@ -624,12 +624,6 @@return 0 ; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#pragma GCC diagnostic ignored "-Wsign-compare" -#endif -#if MBEDTLS_VERSION_NUMBER <0x04000000 /** * external_pkcs1_sign implements a mbed TLS rsa_sign_func callback, that uses
@@ -656,7 +650,6 @@ {struct external_context *const ctx = ctx_voidptr;int rv; -uint8_t *to_sign =NULL ;size_t asn_len =0 , oid_size =0 ;const char *oid =NULL ;
@@ -688,11 +681,13 @@ asn_len =10 + oid_size; } -if ((SIZE_MAX - hashlen) < asn_len || ctx->signature_length < (asn_len + hashlen)) +if (ctx->signature_length < (asn_len + hashlen) + || (asn_len + hashlen) >UINT8_MAX ) {return MBEDTLS_ERR_RSA_BAD_INPUT_DATA ; } +uint8_t *to_sign =NULL ;ALLOC_ARRAY_CLEAR (to_sign, uint8_t, asn_len + hashlen);uint8_t *p = to_sign;if (md_alg !=MBEDTLS_MD_NONE )
@@ -707,20 +702,20 @@* Digest ::= OCTET STRING */ *p++ =MBEDTLS_ASN1_SEQUENCE |MBEDTLS_ASN1_CONSTRUCTED ; - *p++ = (unsigned char )(0x08 + oid_size + hashlen); + *p++ = (uint8_t )(0x08 + oid_size + hashlen); *p++ =MBEDTLS_ASN1_SEQUENCE |MBEDTLS_ASN1_CONSTRUCTED ; - *p++ = (unsigned char )(0x04 + oid_size); + *p++ = (uint8_t )(0x04 + oid_size); *p++ =MBEDTLS_ASN1_OID ; - *p++ = oid_size &0xFF ; + *p++ = (uint8_t )oid_size;memcpy (p, oid, oid_size); p += oid_size; *p++ =MBEDTLS_ASN1_NULL ; *p++ =0x00 ; *p++ =MBEDTLS_ASN1_OCTET_STRING ; - *p++ = hashlen; + *p++ = (uint8_t )hashlen;/* Double-check ASN length */ -ASSERT (asn_len == p - to_sign); +ASSERT (asn_len == (uintptr_t )(p - to_sign)); }/* Copy the hash to be signed */
@@ -810,7 +805,7 @@ goto cleanup; } -if (openvpn_base64_decode (dst_b64, dst, (int )dst_len) != dst_len) +if (openvpn_base64_decode (dst_b64, dst, (int )dst_len) != (int )dst_len) { goto cleanup; }
@@ -923,6 +918,8 @@ {size_t read_len =0 ; +ASSERT (out_len <=INT_MAX ); +if (in->first_block ==NULL ) {return MBEDTLS_ERR_SSL_WANT_READ ;
@@ -930,7 +927,7 @@while (in->first_block !=NULL && read_len < out_len) { -int block_len = in->first_block->length - in->data_start; +size_t block_len = in->first_block->length - in->data_start;if (block_len <= out_len - read_len) {buffer_entry *cur_entry = in->first_block;
@@ -956,7 +953,7 @@ } } -return read_len; +return (int )read_len; } static int
@@ -975,6 +972,8 @@return MBEDTLS_ERR_NET_SEND_FAILED ; } +ASSERT (len <=INT_MAX ); + new_block->length = len; new_block->next_block =NULL ;
@@ -992,7 +991,7 @@ out->last_block = new_block; -return len; +return (int )len; } static int
@@ -1012,7 +1011,7 @@static void my_debug (void *ctx,int level,const char *file,int line,const char *str) { -int my_loglevel = (level <3 ) ?D_TLS_DEBUG_MED :D_TLS_DEBUG ; +msglvl_t my_loglevel = (level <3 ) ?D_TLS_DEBUG_MED :D_TLS_DEBUG ;msg (my_loglevel,"mbed TLS msg (%s:%d): %s" , file, line, str); }
@@ -1048,10 +1047,6 @@#endif /* MBEDTLS_VERSION_NUMBER < 0x040000 */ } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif -int tls_version_max (void ) {
src/openvpn/ssl_verify_mbedtls.c +0 -9
@@ -565,11 +565,6 @@gc_free (&gc); } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsign-compare" -#endif -/* * Save X509 fields to environment, using the naming convention: *
@@ -678,10 +673,6 @@return fFound; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif -result_t x509_verify_cert_eku (mbedtls_x509_crt *cert,const char *const expected_oid) {
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1559?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I777a3a5f4f137432a19746972e2aad1732184feb
Gerrit-Change-Number: 1559
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Attention is currently required from: flichtenheld, plaisthos.
cron2 has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1559?usp=email )
Change subject: ssl_mbedtls: Avoid conversion and sign-compare warnings
......................................................................
Patch Set 4: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1559?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I777a3a5f4f137432a19746972e2aad1732184feb
Gerrit-Change-Number: 1559
Gerrit-PatchSet: 4
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Sat, 14 Mar 2026 17:09:32 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
PATCH v4 1/1 ssl_mbedtls: Avoid conversion and sign-compare warnings
In reply to a message not in the archiveFrom: Frank Lichtenheld <[email protected]...>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1559
---
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/+/1559
This mail reflects revision 4 of this Change.
Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>
src/openvpn/ssl_mbedtls.c +17 -22
@@ -624,12 +624,6 @@return 0 ; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#pragma GCC diagnostic ignored "-Wsign-compare" -#endif -#if MBEDTLS_VERSION_NUMBER <0x04000000 /** * external_pkcs1_sign implements a mbed TLS rsa_sign_func callback, that uses
@@ -656,7 +650,6 @@ {struct external_context *const ctx = ctx_voidptr;int rv; -uint8_t *to_sign =NULL ;size_t asn_len =0 , oid_size =0 ;const char *oid =NULL ;
@@ -688,11 +681,13 @@ asn_len =10 + oid_size; } -if ((SIZE_MAX - hashlen) < asn_len || ctx->signature_length < (asn_len + hashlen)) +if (ctx->signature_length < (asn_len + hashlen) + || (asn_len + hashlen) >UINT8_MAX ) {return MBEDTLS_ERR_RSA_BAD_INPUT_DATA ; } +uint8_t *to_sign =NULL ;ALLOC_ARRAY_CLEAR (to_sign, uint8_t, asn_len + hashlen);uint8_t *p = to_sign;if (md_alg !=MBEDTLS_MD_NONE )
@@ -707,20 +702,20 @@* Digest ::= OCTET STRING */ *p++ =MBEDTLS_ASN1_SEQUENCE |MBEDTLS_ASN1_CONSTRUCTED ; - *p++ = (unsigned char )(0x08 + oid_size + hashlen); + *p++ = (uint8_t )(0x08 + oid_size + hashlen); *p++ =MBEDTLS_ASN1_SEQUENCE |MBEDTLS_ASN1_CONSTRUCTED ; - *p++ = (unsigned char )(0x04 + oid_size); + *p++ = (uint8_t )(0x04 + oid_size); *p++ =MBEDTLS_ASN1_OID ; - *p++ = oid_size &0xFF ; + *p++ = (uint8_t )oid_size;memcpy (p, oid, oid_size); p += oid_size; *p++ =MBEDTLS_ASN1_NULL ; *p++ =0x00 ; *p++ =MBEDTLS_ASN1_OCTET_STRING ; - *p++ = hashlen; + *p++ = (uint8_t )hashlen;/* Double-check ASN length */ -ASSERT (asn_len == p - to_sign); +ASSERT (asn_len == (uintptr_t )(p - to_sign)); }/* Copy the hash to be signed */
@@ -810,7 +805,7 @@ goto cleanup; } -if (openvpn_base64_decode (dst_b64, dst, (int )dst_len) != dst_len) +if (openvpn_base64_decode (dst_b64, dst, (int )dst_len) != (int )dst_len) { goto cleanup; }
@@ -923,6 +918,8 @@ {size_t read_len =0 ; +ASSERT (out_len <=INT_MAX ); +if (in->first_block ==NULL ) {return MBEDTLS_ERR_SSL_WANT_READ ;
@@ -930,7 +927,7 @@while (in->first_block !=NULL && read_len < out_len) { -int block_len = in->first_block->length - in->data_start; +size_t block_len = in->first_block->length - in->data_start;if (block_len <= out_len - read_len) {buffer_entry *cur_entry = in->first_block;
@@ -956,7 +953,7 @@ } } -return read_len; +return (int )read_len; } static int
@@ -975,6 +972,8 @@return MBEDTLS_ERR_NET_SEND_FAILED ; } +ASSERT (len <=INT_MAX ); + new_block->length = len; new_block->next_block =NULL ;
@@ -992,7 +991,7 @@ out->last_block = new_block; -return len; +return (int )len; } static int
@@ -1012,7 +1011,7 @@static void my_debug (void *ctx,int level,const char *file,int line,const char *str) { -int my_loglevel = (level <3 ) ?D_TLS_DEBUG_MED :D_TLS_DEBUG ; +msglvl_t my_loglevel = (level <3 ) ?D_TLS_DEBUG_MED :D_TLS_DEBUG ;msg (my_loglevel,"mbed TLS msg (%s:%d): %s" , file, line, str); }
@@ -1048,10 +1047,6 @@#endif /* MBEDTLS_VERSION_NUMBER < 0x040000 */ } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif -int tls_version_max (void ) {
src/openvpn/ssl_verify_mbedtls.c +0 -9
@@ -565,11 +565,6 @@gc_free (&gc); } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsign-compare" -#endif -/* * Save X509 fields to environment, using the naming convention: *
@@ -678,10 +673,6 @@return fFound; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif -result_t x509_verify_cert_eku (mbedtls_x509_crt *cert,const char *const expected_oid) {
[Openvpn-devel] [PATCH applied] Re: ssl_mbedtls: Avoid conversion and sign-compare warnings
Makes sense. The overflow check is much easier to understand this way, too.
BB confirms that we're not hitting these ASSERT()s either :-) - in addition to that, tested on FreeBSD 14 to see if I messed up apply ordering, creating new -Werror fails (no).
(JFTR, v5 is just a rebase of v4)
Your patch has been applied to the master branch.
commit a04a3cedd41a3b552e56d19dafc7042b95dd527d
Author: Frank Lichtenheld Date: Sat Mar 14 18:09:43 2026 +0100
ssl_mbedtls: Avoid conversion and sign-compare warnings
Signed-off-by: Frank Lichtenheld <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1559
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg36137.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
Attention is currently required from: flichtenheld, plaisthos.
Hello cron2, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/1559?usp=email
to look at the new patch set (#5).
The change is no longer submittable: checks~ChecksSubmitRule is unsatisfied now.
Change subject: ssl_mbedtls: Avoid conversion and sign-compare warnings
......................................................................
ssl_mbedtls: Avoid conversion and sign-compare warnings
---
M src/openvpn/ssl_mbedtls.c
M src/openvpn/ssl_verify_mbedtls.c
2 files changed, 17 insertions(+), 31 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/59/1559/5
src/openvpn/ssl_mbedtls.c +17 -22
@@ -624,12 +624,6 @@return 0 ; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#pragma GCC diagnostic ignored "-Wsign-compare" -#endif -#if MBEDTLS_VERSION_NUMBER <0x04000000 /** * external_pkcs1_sign implements a mbed TLS rsa_sign_func callback, that uses
@@ -656,7 +650,6 @@ {struct external_context *const ctx = ctx_voidptr;int rv; -uint8_t *to_sign =NULL ;size_t asn_len =0 , oid_size =0 ;const char *oid =NULL ;
@@ -688,11 +681,13 @@ asn_len =10 + oid_size; } -if ((SIZE_MAX - hashlen) < asn_len || ctx->signature_length < (asn_len + hashlen)) +if (ctx->signature_length < (asn_len + hashlen) + || (asn_len + hashlen) >UINT8_MAX ) {return MBEDTLS_ERR_RSA_BAD_INPUT_DATA ; } +uint8_t *to_sign =NULL ;ALLOC_ARRAY_CLEAR (to_sign, uint8_t, asn_len + hashlen);uint8_t *p = to_sign;if (md_alg !=MBEDTLS_MD_NONE )
@@ -707,20 +702,20 @@* Digest ::= OCTET STRING */ *p++ =MBEDTLS_ASN1_SEQUENCE |MBEDTLS_ASN1_CONSTRUCTED ; - *p++ = (unsigned char )(0x08 + oid_size + hashlen); + *p++ = (uint8_t )(0x08 + oid_size + hashlen); *p++ =MBEDTLS_ASN1_SEQUENCE |MBEDTLS_ASN1_CONSTRUCTED ; - *p++ = (unsigned char )(0x04 + oid_size); + *p++ = (uint8_t )(0x04 + oid_size); *p++ =MBEDTLS_ASN1_OID ; - *p++ = oid_size &0xFF ; + *p++ = (uint8_t )oid_size;memcpy (p, oid, oid_size); p += oid_size; *p++ =MBEDTLS_ASN1_NULL ; *p++ =0x00 ; *p++ =MBEDTLS_ASN1_OCTET_STRING ; - *p++ = hashlen; + *p++ = (uint8_t )hashlen;/* Double-check ASN length */ -ASSERT (asn_len == p - to_sign); +ASSERT (asn_len == (uintptr_t )(p - to_sign)); }/* Copy the hash to be signed */
@@ -810,7 +805,7 @@ goto cleanup; } -if (openvpn_base64_decode (dst_b64, dst, (int )dst_len) != dst_len) +if (openvpn_base64_decode (dst_b64, dst, (int )dst_len) != (int )dst_len) { goto cleanup; }
@@ -923,6 +918,8 @@ {size_t read_len =0 ; +ASSERT (out_len <=INT_MAX ); +if (in->first_block ==NULL ) {return MBEDTLS_ERR_SSL_WANT_READ ;
@@ -930,7 +927,7 @@while (in->first_block !=NULL && read_len < out_len) { -int block_len = in->first_block->length - in->data_start; +size_t block_len = in->first_block->length - in->data_start;if (block_len <= out_len - read_len) {buffer_entry *cur_entry = in->first_block;
@@ -956,7 +953,7 @@ } } -return read_len; +return (int )read_len; } static int
@@ -975,6 +972,8 @@return MBEDTLS_ERR_NET_SEND_FAILED ; } +ASSERT (len <=INT_MAX ); + new_block->length = len; new_block->next_block =NULL ;
@@ -992,7 +991,7 @@ out->last_block = new_block; -return len; +return (int )len; } static int
@@ -1012,7 +1011,7 @@static void my_debug (void *ctx,int level,const char *file,int line,const char *str) { -int my_loglevel = (level <3 ) ?D_TLS_DEBUG_MED :D_TLS_DEBUG ; +msglvl_t my_loglevel = (level <3 ) ?D_TLS_DEBUG_MED :D_TLS_DEBUG ;msg (my_loglevel,"mbed TLS msg (%s:%d): %s" , file, line, str); }
@@ -1048,10 +1047,6 @@#endif /* MBEDTLS_VERSION_NUMBER < 0x040000 */ } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif -int tls_version_max (void ) {
src/openvpn/ssl_verify_mbedtls.c +0 -9
@@ -565,11 +565,6 @@gc_free (&gc); } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsign-compare" -#endif -/* * Save X509 fields to environment, using the naming convention: *
@@ -678,10 +673,6 @@return fFound; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif -result_t x509_verify_cert_eku (mbedtls_x509_crt *cert,const char *const expected_oid) {
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1559?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I777a3a5f4f137432a19746972e2aad1732184feb
Gerrit-Change-Number: 1559
Gerrit-PatchSet: 5
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
cron2 has uploaded a new patch set (#6) to the change originally created by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1559?usp=email )
The following approvals got outdated and were removed:
Code-Review+2 by cron2
Change subject: ssl_mbedtls: Avoid conversion and sign-compare warnings
......................................................................
ssl_mbedtls: Avoid conversion and sign-compare warnings
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1559
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg36137.html
---
M src/openvpn/ssl_mbedtls.c
M src/openvpn/ssl_verify_mbedtls.c
2 files changed, 17 insertions(+), 31 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/59/1559/6
src/openvpn/ssl_mbedtls.c +17 -22
@@ -624,12 +624,6 @@return 0 ; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#pragma GCC diagnostic ignored "-Wsign-compare" -#endif -#if MBEDTLS_VERSION_NUMBER <0x04000000 /** * external_pkcs1_sign implements a mbed TLS rsa_sign_func callback, that uses
@@ -656,7 +650,6 @@ {struct external_context *const ctx = ctx_voidptr;int rv; -uint8_t *to_sign =NULL ;size_t asn_len =0 , oid_size =0 ;const char *oid =NULL ;
@@ -688,11 +681,13 @@ asn_len =10 + oid_size; } -if ((SIZE_MAX - hashlen) < asn_len || ctx->signature_length < (asn_len + hashlen)) +if (ctx->signature_length < (asn_len + hashlen) + || (asn_len + hashlen) >UINT8_MAX ) {return MBEDTLS_ERR_RSA_BAD_INPUT_DATA ; } +uint8_t *to_sign =NULL ;ALLOC_ARRAY_CLEAR (to_sign, uint8_t, asn_len + hashlen);uint8_t *p = to_sign;if (md_alg !=MBEDTLS_MD_NONE )
@@ -707,20 +702,20 @@* Digest ::= OCTET STRING */ *p++ =MBEDTLS_ASN1_SEQUENCE |MBEDTLS_ASN1_CONSTRUCTED ; - *p++ = (unsigned char )(0x08 + oid_size + hashlen); + *p++ = (uint8_t )(0x08 + oid_size + hashlen); *p++ =MBEDTLS_ASN1_SEQUENCE |MBEDTLS_ASN1_CONSTRUCTED ; - *p++ = (unsigned char )(0x04 + oid_size); + *p++ = (uint8_t )(0x04 + oid_size); *p++ =MBEDTLS_ASN1_OID ; - *p++ = oid_size &0xFF ; + *p++ = (uint8_t )oid_size;memcpy (p, oid, oid_size); p += oid_size; *p++ =MBEDTLS_ASN1_NULL ; *p++ =0x00 ; *p++ =MBEDTLS_ASN1_OCTET_STRING ; - *p++ = hashlen; + *p++ = (uint8_t )hashlen;/* Double-check ASN length */ -ASSERT (asn_len == p - to_sign); +ASSERT (asn_len == (uintptr_t )(p - to_sign)); }/* Copy the hash to be signed */
@@ -810,7 +805,7 @@ goto cleanup; } -if (openvpn_base64_decode (dst_b64, dst, (int )dst_len) != dst_len) +if (openvpn_base64_decode (dst_b64, dst, (int )dst_len) != (int )dst_len) { goto cleanup; }
@@ -923,6 +918,8 @@ {size_t read_len =0 ; +ASSERT (out_len <=INT_MAX ); +if (in->first_block ==NULL ) {return MBEDTLS_ERR_SSL_WANT_READ ;
@@ -930,7 +927,7 @@while (in->first_block !=NULL && read_len < out_len) { -int block_len = in->first_block->length - in->data_start; +size_t block_len = in->first_block->length - in->data_start;if (block_len <= out_len - read_len) {buffer_entry *cur_entry = in->first_block;
@@ -956,7 +953,7 @@ } } -return read_len; +return (int )read_len; } static int
@@ -975,6 +972,8 @@return MBEDTLS_ERR_NET_SEND_FAILED ; } +ASSERT (len <=INT_MAX ); + new_block->length = len; new_block->next_block =NULL ;
@@ -992,7 +991,7 @@ out->last_block = new_block; -return len; +return (int )len; } static int
@@ -1012,7 +1011,7 @@static void my_debug (void *ctx,int level,const char *file,int line,const char *str) { -int my_loglevel = (level <3 ) ?D_TLS_DEBUG_MED :D_TLS_DEBUG ; +msglvl_t my_loglevel = (level <3 ) ?D_TLS_DEBUG_MED :D_TLS_DEBUG ;msg (my_loglevel,"mbed TLS msg (%s:%d): %s" , file, line, str); }
@@ -1048,10 +1047,6 @@#endif /* MBEDTLS_VERSION_NUMBER < 0x040000 */ } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif -int tls_version_max (void ) {
src/openvpn/ssl_verify_mbedtls.c +0 -9
@@ -565,11 +565,6 @@gc_free (&gc); } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsign-compare" -#endif -/* * Save X509 fields to environment, using the naming convention: *
@@ -678,10 +673,6 @@return fFound; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif -result_t x509_verify_cert_eku (mbedtls_x509_crt *cert,const char *const expected_oid) {
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1559?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I777a3a5f4f137432a19746972e2aad1732184feb
Gerrit-Change-Number: 1559
Gerrit-PatchSet: 6
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1559?usp=email )
Change subject: ssl_mbedtls: Avoid conversion and sign-compare warnings
......................................................................
ssl_mbedtls: Avoid conversion and sign-compare warnings
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1559
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg36137.html
---
M src/openvpn/ssl_mbedtls.c
M src/openvpn/ssl_verify_mbedtls.c
2 files changed, 17 insertions(+), 31 deletions(-)
src/openvpn/ssl_mbedtls.c +17 -22
@@ -624,12 +624,6 @@return 0 ; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#pragma GCC diagnostic ignored "-Wsign-compare" -#endif -#if MBEDTLS_VERSION_NUMBER <0x04000000 /** * external_pkcs1_sign implements a mbed TLS rsa_sign_func callback, that uses
@@ -656,7 +650,6 @@ {struct external_context *const ctx = ctx_voidptr;int rv; -uint8_t *to_sign =NULL ;size_t asn_len =0 , oid_size =0 ;const char *oid =NULL ;
@@ -688,11 +681,13 @@ asn_len =10 + oid_size; } -if ((SIZE_MAX - hashlen) < asn_len || ctx->signature_length < (asn_len + hashlen)) +if (ctx->signature_length < (asn_len + hashlen) + || (asn_len + hashlen) >UINT8_MAX ) {return MBEDTLS_ERR_RSA_BAD_INPUT_DATA ; } +uint8_t *to_sign =NULL ;ALLOC_ARRAY_CLEAR (to_sign, uint8_t, asn_len + hashlen);uint8_t *p = to_sign;if (md_alg !=MBEDTLS_MD_NONE )
@@ -707,20 +702,20 @@* Digest ::= OCTET STRING */ *p++ =MBEDTLS_ASN1_SEQUENCE |MBEDTLS_ASN1_CONSTRUCTED ; - *p++ = (unsigned char )(0x08 + oid_size + hashlen); + *p++ = (uint8_t )(0x08 + oid_size + hashlen); *p++ =MBEDTLS_ASN1_SEQUENCE |MBEDTLS_ASN1_CONSTRUCTED ; - *p++ = (unsigned char )(0x04 + oid_size); + *p++ = (uint8_t )(0x04 + oid_size); *p++ =MBEDTLS_ASN1_OID ; - *p++ = oid_size &0xFF ; + *p++ = (uint8_t )oid_size;memcpy (p, oid, oid_size); p += oid_size; *p++ =MBEDTLS_ASN1_NULL ; *p++ =0x00 ; *p++ =MBEDTLS_ASN1_OCTET_STRING ; - *p++ = hashlen; + *p++ = (uint8_t )hashlen;/* Double-check ASN length */ -ASSERT (asn_len == p - to_sign); +ASSERT (asn_len == (uintptr_t )(p - to_sign)); }/* Copy the hash to be signed */
@@ -810,7 +805,7 @@ goto cleanup; } -if (openvpn_base64_decode (dst_b64, dst, (int )dst_len) != dst_len) +if (openvpn_base64_decode (dst_b64, dst, (int )dst_len) != (int )dst_len) { goto cleanup; }
@@ -923,6 +918,8 @@ {size_t read_len =0 ; +ASSERT (out_len <=INT_MAX ); +if (in->first_block ==NULL ) {return MBEDTLS_ERR_SSL_WANT_READ ;
@@ -930,7 +927,7 @@while (in->first_block !=NULL && read_len < out_len) { -int block_len = in->first_block->length - in->data_start; +size_t block_len = in->first_block->length - in->data_start;if (block_len <= out_len - read_len) {buffer_entry *cur_entry = in->first_block;
@@ -956,7 +953,7 @@ } } -return read_len; +return (int )read_len; } static int
@@ -975,6 +972,8 @@return MBEDTLS_ERR_NET_SEND_FAILED ; } +ASSERT (len <=INT_MAX ); + new_block->length = len; new_block->next_block =NULL ;
@@ -992,7 +991,7 @@ out->last_block = new_block; -return len; +return (int )len; } static int
@@ -1012,7 +1011,7 @@static void my_debug (void *ctx,int level,const char *file,int line,const char *str) { -int my_loglevel = (level <3 ) ?D_TLS_DEBUG_MED :D_TLS_DEBUG ; +msglvl_t my_loglevel = (level <3 ) ?D_TLS_DEBUG_MED :D_TLS_DEBUG ;msg (my_loglevel,"mbed TLS msg (%s:%d): %s" , file, line, str); }
@@ -1048,10 +1047,6 @@#endif /* MBEDTLS_VERSION_NUMBER < 0x040000 */ } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif -int tls_version_max (void ) {
src/openvpn/ssl_verify_mbedtls.c +0 -9
@@ -565,11 +565,6 @@gc_free (&gc); } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsign-compare" -#endif -/* * Save X509 fields to environment, using the naming convention: *
@@ -678,10 +673,6 @@return fFound; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif -result_t x509_verify_cert_eku (mbedtls_x509_crt *cert,const char *const expected_oid) {
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1559?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I777a3a5f4f137432a19746972e2aad1732184feb
Gerrit-Change-Number: 1559
Gerrit-PatchSet: 6
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>