mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 10:47:28 +02:00
Resolved sanitizer issue.
This commit is contained in:
12
src/crl.c
12
src/crl.c
@ -102,10 +102,12 @@ static int InitCRL_Entry(CRL_Entry* crle, DecodedCRL* dcrl, const byte* buff,
|
||||
|
||||
#if defined(OPENSSL_EXTRA)
|
||||
crle->lastDateAsn1.length = MAX_DATE_SIZE;
|
||||
XMEMCPY (crle->lastDateAsn1.data, crle->lastDate, crle->lastDateAsn1.length);
|
||||
XMEMCPY (crle->lastDateAsn1.data, crle->lastDate,
|
||||
crle->lastDateAsn1.length);
|
||||
crle->lastDateAsn1.type = crle->lastDateFormat;
|
||||
crle->nextDateAsn1.length = MAX_DATE_SIZE;
|
||||
XMEMCPY (crle->nextDateAsn1.data, crle->nextDate, crle->nextDateAsn1.length);
|
||||
XMEMCPY (crle->nextDateAsn1.data, crle->nextDate,
|
||||
crle->nextDateAsn1.length);
|
||||
crle->nextDateAsn1.type = crle->nextDateFormat;
|
||||
|
||||
crle->issuer = NULL;
|
||||
@ -706,10 +708,12 @@ static CRL_Entry* DupCRL_Entry(const CRL_Entry* ent, void* heap)
|
||||
|
||||
#if defined(OPENSSL_EXTRA)
|
||||
dupl->lastDateAsn1.length = MAX_DATE_SIZE;
|
||||
XMEMCPY (dupl->lastDateAsn1.data, dupl->lastDate, dupl->lastDateAsn1.length);
|
||||
XMEMCPY (dupl->lastDateAsn1.data, dupl->lastDate,
|
||||
dupl->lastDateAsn1.length);
|
||||
dupl->lastDateAsn1.type = dupl->lastDateFormat;
|
||||
dupl->nextDateAsn1.length = MAX_DATE_SIZE;
|
||||
XMEMCPY (dupl->nextDateAsn1.data, dupl->nextDate, dupl->nextDateAsn1.length);
|
||||
XMEMCPY (dupl->nextDateAsn1.data, dupl->nextDate,
|
||||
dupl->nextDateAsn1.length);
|
||||
dupl->nextDateAsn1.type = dupl->nextDateFormat;
|
||||
#endif
|
||||
|
||||
|
15
src/ocsp.c
15
src/ocsp.c
@ -1074,24 +1074,26 @@ WOLFSSL_OCSP_CERTID* wolfSSL_d2i_OCSP_CERTID(WOLFSSL_OCSP_CERTID** cidOut,
|
||||
{
|
||||
WOLFSSL_OCSP_CERTID *cid = NULL;
|
||||
|
||||
if ((cidOut != NULL) && (derIn != NULL) && (length > 0)) {
|
||||
if ((cidOut != NULL) && (derIn != NULL) && (*derIn != NULL) &&
|
||||
(length > 0)) {
|
||||
|
||||
cid = *cidOut;
|
||||
|
||||
/* If a NULL is passed we allocate the memory for the caller. */
|
||||
if (cid == NULL)
|
||||
if (cid == NULL) {
|
||||
cid = (WOLFSSL_OCSP_CERTID*)XMALLOC(sizeof(*cid), NULL,
|
||||
DYNAMIC_TYPE_OPENSSL);
|
||||
else if (cid->rawCertId) {
|
||||
}
|
||||
else if (cid->rawCertId != NULL) {
|
||||
XFREE(cid->rawCertId, NULL, DYNAMIC_TYPE_OPENSSL);
|
||||
cid->rawCertId = NULL;
|
||||
cid->rawCertIdSize = 0;
|
||||
}
|
||||
|
||||
if (cid != NULL) {
|
||||
cid->rawCertId = (byte*)XMALLOC(length, NULL, DYNAMIC_TYPE_OPENSSL);
|
||||
cid->rawCertId = (byte*)XMALLOC(length + 1, NULL, DYNAMIC_TYPE_OPENSSL);
|
||||
if (cid->rawCertId != NULL) {
|
||||
XMEMCPY (cid->rawCertId, *derIn, length);
|
||||
XMEMCPY(cid->rawCertId, *derIn, length);
|
||||
cid->rawCertIdSize = length;
|
||||
|
||||
/* Per spec. advance past the data that is being returned
|
||||
@ -1104,8 +1106,9 @@ WOLFSSL_OCSP_CERTID* wolfSSL_d2i_OCSP_CERTID(WOLFSSL_OCSP_CERTID** cidOut,
|
||||
}
|
||||
}
|
||||
|
||||
if (cid && (!cidOut || cid != *cidOut))
|
||||
if (cid && (!cidOut || cid != *cidOut)) {
|
||||
XFREE(cid, NULL, DYNAMIC_TYPE_OPENSSL);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -48158,6 +48158,8 @@ static int test_wolfSSL_d2i_OCSP_CERTID(void)
|
||||
DYNAMIC_TYPE_TMP_BUFFER);
|
||||
XMEMSET(certId, 0, sizeof(*certId));
|
||||
|
||||
/* Reset rawCertIdPtr since it was push forward in the previous call. */
|
||||
rawCertIdPtr = &rawCertId[0];
|
||||
certId = wolfSSL_d2i_OCSP_CERTID(&certId, &rawCertIdPtr, sizeof(rawCertId));
|
||||
|
||||
AssertNotNull(certId);
|
||||
|
Reference in New Issue
Block a user