forked from wolfSSL/wolfssl
Merge pull request #4590 from JacobBarthelmeh/fuzzing
sanity check on pem size
This commit is contained in:
28
src/ssl.c
28
src/ssl.c
@ -43264,10 +43264,11 @@ cleanup:
|
|||||||
return NULL;
|
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)
|
if (pem == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
XMEMSET(pem, 0, l);
|
XMEMSET(pem, 0, pemSz);
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
if (wc_PemGetHeaderFooter(type, NULL, &footer) != 0) {
|
if (wc_PemGetHeaderFooter(type, NULL, &footer) != 0) {
|
||||||
@ -43301,15 +43302,20 @@ cleanup:
|
|||||||
#else
|
#else
|
||||||
(void)l;
|
(void)l;
|
||||||
#endif
|
#endif
|
||||||
pemSz = (int)i;
|
if (i > pemSz) {
|
||||||
#ifdef WOLFSSL_CERT_REQ
|
WOLFSSL_MSG("Error parsing PEM");
|
||||||
if (type == CERTREQ_TYPE)
|
}
|
||||||
x509 = wolfSSL_X509_REQ_load_certificate_buffer(pem, pemSz,
|
else {
|
||||||
WOLFSSL_FILETYPE_PEM);
|
pemSz = (int)i;
|
||||||
else
|
#ifdef WOLFSSL_CERT_REQ
|
||||||
#endif
|
if (type == CERTREQ_TYPE)
|
||||||
x509 = wolfSSL_X509_load_certificate_buffer(pem, pemSz,
|
x509 = wolfSSL_X509_REQ_load_certificate_buffer(pem, pemSz,
|
||||||
WOLFSSL_FILETYPE_PEM);
|
WOLFSSL_FILETYPE_PEM);
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
x509 = wolfSSL_X509_load_certificate_buffer(pem, pemSz,
|
||||||
|
WOLFSSL_FILETYPE_PEM);
|
||||||
|
}
|
||||||
|
|
||||||
if (x != NULL) {
|
if (x != NULL) {
|
||||||
*x = x509;
|
*x = x509;
|
||||||
|
Reference in New Issue
Block a user