From d71776aceda16764c422e316d2922fc509f94e62 Mon Sep 17 00:00:00 2001 From: JacobBarthelmeh Date: Sun, 17 Mar 2024 23:31:37 +0700 Subject: [PATCH 1/2] coverity CID 352930, fix for out of bounds write --- wolfcrypt/src/tfm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wolfcrypt/src/tfm.c b/wolfcrypt/src/tfm.c index ae58e857b..07cd1fedc 100644 --- a/wolfcrypt/src/tfm.c +++ b/wolfcrypt/src/tfm.c @@ -1104,9 +1104,9 @@ void fp_mod_2d(fp_int *a, int b, fp_int *c) bmax = ((unsigned int)b + DIGIT_BIT - 1) / DIGIT_BIT; - /* If a is negative and bmax is larger than FP_SIZE, then the + /* If a is negative and bmax is greater than or equal to FP_SIZE, then the * result can't fit within c. Just return. */ - if (c->sign == FP_NEG && bmax > FP_SIZE) { + if (c->sign == FP_NEG && bmax >= FP_SIZE) { return; } From 763c4a074c0de2b59d2d3c27e561fa60063eda2d Mon Sep 17 00:00:00 2001 From: JacobBarthelmeh Date: Sun, 17 Mar 2024 23:54:56 +0700 Subject: [PATCH 2/2] CID 315823 truncate on cast --- wolfcrypt/src/asn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index e3c252b4f..3c44525e3 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -14855,7 +14855,7 @@ int wc_ValidateDate(const byte* date, byte format, int dateType) ltime = wc_Time(0); #ifndef NO_TIME_SIGNEDNESS_CHECK - if (sizeof(ltime) == sizeof(word32) && (int)ltime < 0){ + if (sizeof(ltime) == sizeof(word32) && (sword32)ltime < 0){ /* A negative response here could be due to a 32-bit time_t * where the year is 2038 or later. */ WOLFSSL_MSG("wc_Time failed to return a valid value");