From 75e807abc6bcc73ebb655bac5c42b0b521bc4e0f Mon Sep 17 00:00:00 2001 From: Elms Date: Wed, 30 Jun 2021 22:08:29 -0700 Subject: [PATCH] Fixes for gcc-10 and `-fsanitize=undefined` for rabbit.c * One introduced in #4156 * One from previous commit in this PR --- src/internal.c | 2 +- src/ssl.c | 2 +- wolfcrypt/src/rabbit.c | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/internal.c b/src/internal.c index 03a61f728..2d9877e7e 100644 --- a/src/internal.c +++ b/src/internal.c @@ -20470,7 +20470,7 @@ int SetCipherList(WOLFSSL_CTX* ctx, Suites* suites, const char* list) word32 length; next = XSTRSTR(next, ":"); - length = MAX_SUITE_NAME + 1; + length = MAX_SUITE_NAME; if (next != NULL) { word32 currLen = (word32)(next - current); if (length > currLen) { diff --git a/src/ssl.c b/src/ssl.c index 98de82ae8..de5fc28ab 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -26312,7 +26312,7 @@ int wolfSSL_X509_VERIFY_PARAM_set1_ip_asc(WOLFSSL_X509_VERIFY_PARAM *param, param->ipasc[0] = '\0'; } else { - XSTRNCPY(param->ipasc, ipasc, WOLFSSL_MAX_IPSTR); + XSTRNCPY(param->ipasc, ipasc, WOLFSSL_MAX_IPSTR - 1); param->ipasc[WOLFSSL_MAX_IPSTR-1] = '\0'; } ret = WOLFSSL_SUCCESS; diff --git a/wolfcrypt/src/rabbit.c b/wolfcrypt/src/rabbit.c index 54e9f55d9..c79155f84 100644 --- a/wolfcrypt/src/rabbit.c +++ b/wolfcrypt/src/rabbit.c @@ -156,10 +156,10 @@ static WC_INLINE int DoKey(Rabbit* ctx, const byte* key, const byte* iv) word32 k0, k1, k2, k3, i; /* Generate four subkeys */ - k0 = LITTLE32(((word32*)key)[0]); - k1 = LITTLE32(((word32*)key)[1]); - k2 = LITTLE32(((word32*)key)[2]); - k3 = LITTLE32(((word32*)key)[3]); + k0 = LOAD_LE32(key + 0); + k1 = LOAD_LE32(key + 4); + k2 = LOAD_LE32(key + 8); + k3 = LOAD_LE32(key + 12); /* Generate initial state variables */ ctx->masterCtx.x[0] = k0;