forked from wolfSSL/wolfssl
Merge pull request #4590 from JacobBarthelmeh/fuzzing
sanity check on pem size
This commit is contained in:
10
src/ssl.c
10
src/ssl.c
@ -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;
|
||||
|
Reference in New Issue
Block a user