From 047c662af82418c87e598f59e2231292accf86f3 Mon Sep 17 00:00:00 2001 From: Daniel Pouzzner Date: Fri, 24 Jun 2022 15:56:54 -0500 Subject: [PATCH] fix math errors unmasked by change to sp-math-all as default math back end. --- src/x509.c | 2 +- wolfcrypt/src/sp_int.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/x509.c b/src/x509.c index cff25bf11..d0783d787 100644 --- a/src/x509.c +++ b/src/x509.c @@ -12233,7 +12233,7 @@ int wolfSSL_X509_set_pubkey(WOLFSSL_X509 *cert, WOLFSSL_EVP_PKEY *pkey) int wolfSSL_X509_set_version(WOLFSSL_X509* x509, long v) { WOLFSSL_ENTER("wolfSSL_X509_set_version"); - if ((x509 == NULL) || (v < 0) || (v > INT_MAX)) { + if ((x509 == NULL) || (v < 0) || (v >= INT_MAX)) { return WOLFSSL_FAILURE; } x509->version = (int) v + 1; diff --git a/wolfcrypt/src/sp_int.c b/wolfcrypt/src/sp_int.c index d1c91bdf4..94e12e988 100644 --- a/wolfcrypt/src/sp_int.c +++ b/wolfcrypt/src/sp_int.c @@ -7277,7 +7277,7 @@ static int _sp_mul(sp_int* a, sp_int* b, sp_int* r) #endif for (k = 1; k <= (a->used - 1) + (b->used - 1); k++) { i = k - (b->used - 1); - i &= ~(i >> (sizeof(i) * 8 - 1)); + i &= ~((unsigned int)i >> (sizeof(i) * 8 - 1)); j = k - i; for (; (i < a->used) && (j >= 0); i++, j--) { w = (sp_int_word)a->dp[i] * b->dp[j];