From cc4e8df56d78e8bee9863f7a96744130c54e3ac7 Mon Sep 17 00:00:00 2001 From: JacobBarthelmeh Date: Mon, 26 Sep 2022 10:13:06 -0700 Subject: [PATCH 1/2] cast to fix warning in test case --- tests/api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/api.c b/tests/api.c index 8eb06a988..10ea1d03e 100644 --- a/tests/api.c +++ b/tests/api.c @@ -55869,7 +55869,7 @@ static byte test_AEAD_done = 0; static int test_AEAD_cbiorecv(WOLFSSL *ssl, char *buf, int sz, void *ctx) { - int ret = recv(wolfSSL_get_fd(ssl), buf, sz, 0); + int ret = (int)recv(wolfSSL_get_fd(ssl), buf, sz, 0); if (ret > 0) { if (test_AEAD_fail_decryption) { /* Modify the packet to trigger a decryption failure */ From 1e348eb7bd6cec23c3dc4e65967d4e39353c0b74 Mon Sep 17 00:00:00 2001 From: JacobBarthelmeh Date: Mon, 26 Sep 2022 10:40:41 -0700 Subject: [PATCH 2/2] sanity check on return value --- wolfcrypt/src/sp_int.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/wolfcrypt/src/sp_int.c b/wolfcrypt/src/sp_int.c index a6c28a366..ee841c90d 100644 --- a/wolfcrypt/src/sp_int.c +++ b/wolfcrypt/src/sp_int.c @@ -15631,15 +15631,20 @@ int sp_todecimal(sp_int* a, char* str) i = 0; while (!sp_iszero(t)) { - sp_div_d(t, 10, t, &d); + err = sp_div_d(t, 10, t, &d); + if (err != MP_OKAY) { + break; + } str[i++] = (char)('0' + d); } str[i] = '\0'; - for (j = 0; j <= (i - 1) / 2; j++) { - int c = (unsigned char)str[j]; - str[j] = str[i - 1 - j]; - str[i - 1 - j] = (char)c; + if (err == MP_OKAY) { + for (j = 0; j <= (i - 1) / 2; j++) { + int c = (unsigned char)str[j]; + str[j] = str[i - 1 - j]; + str[i - 1 - j] = (char)c; + } } }