Merge pull request #4590 from JacobBarthelmeh/fuzzing

sanity check on pem size
This commit is contained in:
David Garske
2021-11-22 16:09:13 -08:00
committed by GitHub

View File

@ -43264,10 +43264,11 @@ cleanup:
return NULL;
}
pem = (unsigned char*)XMALLOC(l, 0, DYNAMIC_TYPE_PEM);
pemSz = (int)l;
pem = (unsigned char*)XMALLOC(pemSz, 0, DYNAMIC_TYPE_PEM);
if (pem == NULL)
return NULL;
XMEMSET(pem, 0, l);
XMEMSET(pem, 0, pemSz);
i = 0;
if (wc_PemGetHeaderFooter(type, NULL, &footer) != 0) {
@ -43301,6 +43302,10 @@ cleanup:
#else
(void)l;
#endif
if (i > pemSz) {
WOLFSSL_MSG("Error parsing PEM");
}
else {
pemSz = (int)i;
#ifdef WOLFSSL_CERT_REQ
if (type == CERTREQ_TYPE)
@ -43310,6 +43315,7 @@ cleanup:
#endif
x509 = wolfSSL_X509_load_certificate_buffer(pem, pemSz,
WOLFSSL_FILETYPE_PEM);
}
if (x != NULL) {
*x = x509;