mirror of https://github.com/wolfSSL/wolfssl.git
Fix for vasprintf with AIX
parent
88fb7efb8c
commit
b57294eff7
|
@ -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
|
||||||
|
@ -26151,7 +26151,7 @@ int wolfSSL_BIO_printf(WOLFSSL_BIO* bio, const char* format, ...)
|
||||||
case WOLFSSL_BIO_SSL:
|
case WOLFSSL_BIO_SSL:
|
||||||
{
|
{
|
||||||
char* pt = NULL;
|
char* pt = NULL;
|
||||||
ret = vasprintf(&pt, format, args);
|
ret = XVASPRINTF(&pt, format, args);
|
||||||
if (ret > 0 && pt != NULL) {
|
if (ret > 0 && pt != NULL) {
|
||||||
wolfSSL_BIO_write(bio, pt, ret);
|
wolfSSL_BIO_write(bio, pt, ret);
|
||||||
}
|
}
|
||||||
|
|
|
@ -493,6 +493,58 @@
|
||||||
#endif /* _MSC_VER || __CYGWIN__ || __MINGW32__ */
|
#endif /* _MSC_VER || __CYGWIN__ || __MINGW32__ */
|
||||||
#endif /* USE_WINDOWS_API */
|
#endif /* USE_WINDOWS_API */
|
||||||
|
|
||||||
|
/* XVASPRINTF is used in ssl.c for wolfSSL_BIO_printf */
|
||||||
|
#if (defined(sun) || defined(__sun) || defined(_AIX))
|
||||||
|
#include <stdarg.h>
|
||||||
|
static WC_INLINE
|
||||||
|
int xvasprintf(char **ret, const char *format, va_list args)
|
||||||
|
{
|
||||||
|
int count;
|
||||||
|
char *buffer;
|
||||||
|
va_list copy;
|
||||||
|
va_copy(copy, args);
|
||||||
|
|
||||||
|
*ret = NULL;
|
||||||
|
|
||||||
|
count = vsnprintf(NULL, 0, format, args);
|
||||||
|
if (count >= 0)
|
||||||
|
{
|
||||||
|
buffer = malloc(count + 1);
|
||||||
|
if (buffer == NULL)
|
||||||
|
{
|
||||||
|
count = -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
count = vsnprintf(buffer, count + 1, format, copy);
|
||||||
|
if (count < 0)
|
||||||
|
{
|
||||||
|
free(buffer);
|
||||||
|
count = -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*ret = buffer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
va_end(copy);
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
#define XVASPRINTF xvasprintf
|
||||||
|
#else
|
||||||
|
#ifndef XVASPRINTF
|
||||||
|
#if defined(NO_FILESYSTEM) && (defined(OPENSSL_EXTRA) || \
|
||||||
|
defined(HAVE_PKCS7)) && !defined(NO_STDIO_FILESYSTEM)
|
||||||
|
/* case where stdio is not included else where but is needed
|
||||||
|
for vasprintf */
|
||||||
|
#include <stdio.h>
|
||||||
|
#endif
|
||||||
|
#define XVASPRINTF vasprintf
|
||||||
|
#endif
|
||||||
|
#endif /* defined(sun) || defined(__sun) || defined(_AIX) */
|
||||||
|
|
||||||
#if defined(WOLFSSL_CERT_EXT) || defined(HAVE_ALPN)
|
#if defined(WOLFSSL_CERT_EXT) || defined(HAVE_ALPN)
|
||||||
/* use only Thread Safe version of strtok */
|
/* use only Thread Safe version of strtok */
|
||||||
#if defined(USE_WOLF_STRTOK)
|
#if defined(USE_WOLF_STRTOK)
|
||||||
|
|
Loading…
Reference in New Issue