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> #include <wolfssl/wolfcrypt/settings.h>
#if defined(OPENSSL_EXTRA) && !defined(_WIN32) #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 #undef _GNU_SOURCE
#define _GNU_SOURCE #define _GNU_SOURCE
#endif #endif
@ -26425,14 +26425,27 @@ int wolfSSL_BIO_printf(WOLFSSL_BIO* bio, const char* format, ...)
#if defined(OPENSSL_EXTRA) && !defined(_WIN32) #if defined(OPENSSL_EXTRA) && !defined(_WIN32)
case WOLFSSL_BIO_SSL: case WOLFSSL_BIO_SSL:
{ {
int count;
char* pt = NULL; char* pt = NULL;
ret = vasprintf(&pt, format, args); va_list copy;
if (ret > 0 && pt != NULL) {
wolfSSL_BIO_write(bio, pt, ret); va_copy(copy, args);
} count = vsnprintf(NULL, 0, format, args);
if (pt != NULL) { if (count >= 0)
free(pt); {
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);
}
XFREE(pt, bio->heap, DYNAMIC_TYPE_TMP_BUFFER);
}
} }
va_end(copy);
} }
break; break;
#endif #endif