Fixes for wolfSSL_BIO_BASE64_write changes.

This commit is contained in:
David Garske
2021-04-05 14:35:41 -07:00
parent 1a9d59c185
commit 5ebe5d071f

View File

@@ -332,7 +332,7 @@ static int wolfSSL_BIO_BASE64_write(WOLFSSL_BIO* bio, const void* data,
/* allocate buffer for encoded output */ /* allocate buffer for encoded output */
if (*out == NULL && sz > 0) { if (*out == NULL && sz > 0) {
*out = (void*)XMALLOC(sz, front->heap, *out = (byte*)XMALLOC(sz, front->heap,
DYNAMIC_TYPE_TMP_BUFFER); DYNAMIC_TYPE_TMP_BUFFER);
if (*out == NULL) { if (*out == NULL) {
WOLFSSL_MSG("Memory error"); WOLFSSL_MSG("Memory error");
@@ -340,7 +340,7 @@ static int wolfSSL_BIO_BASE64_write(WOLFSSL_BIO* bio, const void* data,
} }
} }
else if (sz > *outLen) { else if (sz > *outLen) {
tmp = (void*)XREALLOC(*out, sz, front->heap, tmp = (byte*)XREALLOC(*out, sz, front->heap,
DYNAMIC_TYPE_TMP_BUFFER); DYNAMIC_TYPE_TMP_BUFFER);
if (tmp == NULL) { if (tmp == NULL) {
WOLFSSL_MSG("Memory error"); WOLFSSL_MSG("Memory error");
@@ -372,7 +372,9 @@ static int wolfSSL_BIO_BASE64_write(WOLFSSL_BIO* bio, const void* data,
} }
} }
XMEMCPY(*out, tmp, *outLen); if (*out) {
XMEMCPY(*out, tmp, *outLen);
}
XFREE(tmp, bio->heap, DYNAMIC_TYPE_TMP_BUFFER); XFREE(tmp, bio->heap, DYNAMIC_TYPE_TMP_BUFFER);
/* Encode successful */ /* Encode successful */