From 64cd7e7ce2dd6aa514b61b55cf6b07e33ae4583e Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Thu, 31 Oct 2019 16:36:12 +0100 Subject: [PATCH] bignum: Fix integer types for ssh_make_bignum_string() Fixes T188 Signed-off-by: Andreas Schneider Reviewed-by: Jakub Jelen --- include/libssh/libcrypto.h | 6 +++--- src/bignum.c | 10 ++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/libssh/libcrypto.h b/include/libssh/libcrypto.h index fff6ff55..4117942c 100644 --- a/include/libssh/libcrypto.h +++ b/include/libssh/libcrypto.h @@ -96,9 +96,9 @@ typedef BN_CTX* bignum_CTX; #define bignum_add(dest, a, b) BN_add(dest, a, b) #define bignum_sub(dest, a, b) BN_sub(dest, a, b) #define bignum_mod(dest, a, b, ctx) BN_mod(dest, a, b, ctx) -#define bignum_num_bytes(num) BN_num_bytes(num) -#define bignum_num_bits(num) BN_num_bits(num) -#define bignum_is_bit_set(num,bit) BN_is_bit_set(num,bit) +#define bignum_num_bytes(num) (size_t)BN_num_bytes(num) +#define bignum_num_bits(num) (size_t)BN_num_bits(num) +#define bignum_is_bit_set(num,bit) BN_is_bit_set(num, (int)bit) #define bignum_bn2bin(num,len, ptr) BN_bn2bin(num, ptr) #define bignum_cmp(num1,num2) BN_cmp(num1,num2) #define bignum_rshift1(dest, src) BN_rshift1(dest, src) diff --git a/src/bignum.c b/src/bignum.c index e264514a..a2092385 100644 --- a/src/bignum.c +++ b/src/bignum.c @@ -29,9 +29,9 @@ ssh_string ssh_make_bignum_string(bignum num) { ssh_string ptr = NULL; - int pad = 0; - unsigned int len = bignum_num_bytes(num); - unsigned int bits = bignum_num_bits(num); + size_t pad = 0; + size_t len = bignum_num_bytes(num); + size_t bits = bignum_num_bits(num); if (len == 0) { return NULL; @@ -43,7 +43,9 @@ ssh_string ssh_make_bignum_string(bignum num) { } #ifdef DEBUG_CRYPTO - fprintf(stderr, "%d bits, %d bytes, %d padding\n", bits, len, pad); + SSH_LOG(SSH_LOG_TRACE, + "%zu bits, %zu bytes, %zu padding\n", + bits, len, pad); #endif /* DEBUG_CRYPTO */ ptr = ssh_string_new(len + pad);