Merge pull request #2617 from embhorn/zd9553

Fix for vasprintf with AIX
This commit is contained in:
toddouska
2019-12-05 16:15:24 -08:00
committed by GitHub

View File

@ -26,7 +26,7 @@
#include <wolfssl/wolfcrypt/settings.h>
#if defined(OPENSSL_EXTRA) && !defined(_WIN32)
/* turn on GNU extensions for vasprintf with wolfSSL_BIO_printf */
/* turn on GNU extensions for XVASPRINTF with wolfSSL_BIO_printf */
#undef _GNU_SOURCE
#define _GNU_SOURCE
#endif
@ -26425,15 +26425,28 @@ int wolfSSL_BIO_printf(WOLFSSL_BIO* bio, const char* format, ...)
#if defined(OPENSSL_EXTRA) && !defined(_WIN32)
case WOLFSSL_BIO_SSL:
{
int count;
char* pt = NULL;
ret = vasprintf(&pt, format, args);
if (ret > 0 && pt != NULL) {
wolfSSL_BIO_write(bio, pt, ret);
va_list copy;
va_copy(copy, args);
count = vsnprintf(NULL, 0, format, args);
if (count >= 0)
{
pt = (char*)XMALLOC(count + 1, bio->heap,
DYNAMIC_TYPE_TMP_BUFFER);
if (pt != NULL)
{
count = vsnprintf(pt, count + 1, format, copy);
if (count >= 0)
{
ret = wolfSSL_BIO_write(bio, pt, count);
}
if (pt != NULL) {
free(pt);
XFREE(pt, bio->heap, DYNAMIC_TYPE_TMP_BUFFER);
}
}
va_end(copy);
}
break;
#endif