From bb216bd94040c848f6cd6310fb103da00161aa7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Mon, 28 Aug 2017 13:25:55 +0200 Subject: [PATCH] Fix MSVC 64-bit warnings "conversion from size_t to int, possible loss of data" --- include/mbedtls/x509_crt.h | 2 +- library/x509_crt.c | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/mbedtls/x509_crt.h b/include/mbedtls/x509_crt.h index 683181270..a168d7628 100644 --- a/include/mbedtls/x509_crt.h +++ b/include/mbedtls/x509_crt.h @@ -161,7 +161,7 @@ typedef struct { typedef struct { mbedtls_x509_crt_verify_chain_item items[MBEDTLS_X509_MAX_VERIFY_CHAIN_SIZE]; - size_t len; + unsigned len; } mbedtls_x509_crt_verify_chain; #if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) diff --git a/library/x509_crt.c b/library/x509_crt.c index 586ec8375..b3fc6e40c 100644 --- a/library/x509_crt.c +++ b/library/x509_crt.c @@ -1983,8 +1983,8 @@ static int x509_crt_find_parent_in( mbedtls_x509_crt **r_parent, int *r_signature_is_good, int top, - int path_cnt, - int self_cnt, + unsigned path_cnt, + unsigned self_cnt, mbedtls_x509_crt_restart_ctx *rs_ctx ) { int ret; @@ -2021,7 +2021,7 @@ static int x509_crt_find_parent_in( /* +1 because stored max_pathlen is 1 higher that the actual value */ if( parent->max_pathlen > 0 && - parent->max_pathlen < 1 + path_cnt - self_cnt ) + (size_t) parent->max_pathlen < 1 + path_cnt - self_cnt ) { continue; } @@ -2103,8 +2103,8 @@ static int x509_crt_find_parent( mbedtls_x509_crt **parent, int *parent_is_trusted, int *signature_is_good, - int path_cnt, - int self_cnt, + unsigned path_cnt, + unsigned self_cnt, mbedtls_x509_crt_restart_ctx *rs_ctx ) { int ret; @@ -2246,7 +2246,7 @@ static int x509_crt_verify_chain( int parent_is_trusted; int child_is_trusted; int signature_is_good; - int self_cnt; + unsigned self_cnt; #if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) /* resume if we had an operation in progress */ @@ -2445,7 +2445,7 @@ static int x509_crt_merge_flags_with_cb( void *p_vrfy ) { int ret; - size_t i; + unsigned i; uint32_t cur_flags; const mbedtls_x509_crt_verify_chain_item *cur; @@ -2455,7 +2455,7 @@ static int x509_crt_merge_flags_with_cb( cur_flags = cur->flags; if( NULL != f_vrfy ) - if( ( ret = f_vrfy( p_vrfy, cur->crt, i-1, &cur_flags ) ) != 0 ) + if( ( ret = f_vrfy( p_vrfy, cur->crt, (int) i-1, &cur_flags ) ) != 0 ) return( ret ); *flags |= cur_flags;