Merge pull request #4301 from julek-wolfssl/issue-4298

`mem_buf` only used with memory BIO
pull/4484/head
David Garske 2021-10-18 10:29:55 -07:00 committed by GitHub
commit a50d1f4870
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 4 deletions

View File

@ -115,7 +115,7 @@ AC_C_BIGENDIAN
# check if functions of interest are linkable, but also check if
# they're declared by the expected headers, and if not, supersede the
# unusable positive from AC_CHECK_FUNCS().
AC_CHECK_FUNCS([gethostbyname getaddrinfo gettimeofday gmtime_r inet_ntoa memset socket strftime])
AC_CHECK_FUNCS([gethostbyname getaddrinfo gettimeofday gmtime_r inet_ntoa memset socket strftime atexit])
AC_CHECK_DECLS([gethostbyname, getaddrinfo, gettimeofday, gmtime_r, inet_ntoa, memset, socket, strftime], [], [
if test "$(eval echo \$"$(eval 'echo ac_cv_func_${as_decl_name}')")" = "yes"
then

View File

@ -5092,6 +5092,16 @@ int AddCA(WOLFSSL_CERT_MANAGER* cm, DerBuffer** pDer, int type, int verify)
static int wolfSSL_RAND_InitMutex(void);
#endif
#if defined(OPENSSL_EXTRA) && defined(HAVE_ATEXIT)
static void AtExitCleanup(void)
{
if (initRefCount > 0) {
initRefCount = 1;
(void)wolfSSL_Cleanup();
}
}
#endif
WOLFSSL_ABI
int wolfSSL_Init(void)
{
@ -5116,6 +5126,14 @@ int wolfSSL_Init(void)
#endif
#ifdef OPENSSL_EXTRA
#ifdef HAVE_ATEXIT
/* OpenSSL registers cleanup using atexit */
if (atexit(AtExitCleanup) != 0) {
WOLFSSL_MSG("Bad atexit registration");
return WC_INIT_E;
}
#endif
#ifndef WOLFSSL_NO_OPENSSL_RAND_CB
if (wolfSSL_RAND_InitMutex() != 0) {
return BAD_MUTEX_E;
@ -57658,9 +57676,8 @@ int wolfSSL_CONF_cmd(WOLFSSL_CONF_CTX* cctx, const char* cmd, const char* value)
bio->shutdown = BIO_CLOSE; /* default to close things */
bio->num = SOCKET_INVALID; /* Default to invalid socket */
bio->init = 1;
if (method->type != WOLFSSL_BIO_FILE &&
method->type != WOLFSSL_BIO_SOCKET &&
method->type != WOLFSSL_BIO_MD) {
if (method->type == WOLFSSL_BIO_MEMORY ||
method->type == WOLFSSL_BIO_BIO) {
bio->mem_buf =(WOLFSSL_BUF_MEM*)XMALLOC(sizeof(WOLFSSL_BUF_MEM),
0, DYNAMIC_TYPE_OPENSSL);
if (bio->mem_buf == NULL) {