forked from wolfSSL/wolfssl
Merge pull request #2617 from embhorn/zd9553
Fix for vasprintf with AIX
This commit is contained in:
27
src/ssl.c
27
src/ssl.c
@ -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,14 +26425,27 @@ 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);
|
||||
}
|
||||
if (pt != NULL) {
|
||||
free(pt);
|
||||
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);
|
||||
}
|
||||
XFREE(pt, bio->heap, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
}
|
||||
}
|
||||
va_end(copy);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user