Merge pull request #9006 from rlm2002/zd20212

Coverity fixes for Zendesk issue
This commit is contained in:
David Garske
2025-07-23 15:29:20 -07:00
committed by GitHub
4 changed files with 10 additions and 12 deletions

View File

@@ -28850,10 +28850,6 @@ int SetSuitesHashSigAlgo(Suites* suites, const char* list)
do { do {
if (*list == '+') { if (*list == '+') {
if (mac_alg != 0) {
ret = 0;
break;
}
sig_alg = GetSigAlgFromName(s, (int)(list - s)); sig_alg = GetSigAlgFromName(s, (int)(list - s));
if (sig_alg == 0) { if (sig_alg == 0) {
ret = 0; ret = 0;

View File

@@ -1043,7 +1043,6 @@ static int wolfssl_asn1_integer_require_len(WOLFSSL_ASN1_INTEGER* a, int len,
int ret = 1; int ret = 1;
byte* data; byte* data;
byte* oldData = a->intData; byte* oldData = a->intData;
int oldLen = a->length;
if (a->isDynamic && (len > (int)a->dataMax)) { if (a->isDynamic && (len > (int)a->dataMax)) {
oldData = a->data; oldData = a->data;
@@ -1051,7 +1050,6 @@ static int wolfssl_asn1_integer_require_len(WOLFSSL_ASN1_INTEGER* a, int len,
a->data = a->intData; a->data = a->intData;
a->dataMax = (unsigned int)sizeof(a->intData); a->dataMax = (unsigned int)sizeof(a->intData);
} }
a->length = 0;
if ((!a->isDynamic) && (len > (int)a->dataMax)) { if ((!a->isDynamic) && (len > (int)a->dataMax)) {
/* Create a new buffer to hold large integer value. */ /* Create a new buffer to hold large integer value. */
data = (byte*)XMALLOC((size_t)len, NULL, DYNAMIC_TYPE_OPENSSL); data = (byte*)XMALLOC((size_t)len, NULL, DYNAMIC_TYPE_OPENSSL);
@@ -1068,10 +1066,10 @@ static int wolfssl_asn1_integer_require_len(WOLFSSL_ASN1_INTEGER* a, int len,
if (keepOldData) { if (keepOldData) {
if (oldData != a->data) { if (oldData != a->data) {
/* Copy old data into new buffer. */ /* Copy old data into new buffer. */
XMEMCPY(a->data, oldData, (size_t)oldLen); XMEMCPY(a->data, oldData, (size_t)a->length);
} }
/* Restore old length. */ } else {
a->length = oldLen; a->length = 0;
} }
if (oldData != a->intData) { if (oldData != a->intData) {
/* Dispose of the old dynamic data. */ /* Dispose of the old dynamic data. */
@@ -3549,7 +3547,7 @@ int wolfSSL_ASN1_STRING_print_ex(WOLFSSL_BIO *bio, WOLFSSL_ASN1_STRING *str,
} }
} }
if ((!err) && (str_len != -1)) { if ((!err) && (str_len >= 0)) {
/* Include any characters written for type. */ /* Include any characters written for type. */
str_len += type_len; str_len += type_len;
} }

View File

@@ -1017,7 +1017,9 @@ int wc_ed448_import_public_ex(const byte* in, word32 inLen, ed448_key* key,
ret = BAD_FUNC_ARG; ret = BAD_FUNC_ARG;
} }
if ((inLen != ED448_PUB_KEY_SIZE) && (inLen != ED448_PUB_KEY_SIZE + 1)) { if ((inLen != ED448_PUB_KEY_SIZE) &&
(inLen != ED448_PUB_KEY_SIZE + 1) &&
(inLen != 2 * ED448_PUB_KEY_SIZE + 1)) {
ret = BAD_FUNC_ARG; ret = BAD_FUNC_ARG;
} }

View File

@@ -1376,7 +1376,9 @@ void* wolfSSL_Realloc(void *ptr, size_t size, void* heap, int type)
WOLFSSL_MSG("Error IO memory was not large enough"); WOLFSSL_MSG("Error IO memory was not large enough");
res = NULL; /* return NULL in error case */ res = NULL; /* return NULL in error case */
} }
res = pt->buffer; else {
res = pt->buffer;
}
} }
else else
#endif #endif