From 3821ece32bee2ae004e2580b81174b639eafd15d Mon Sep 17 00:00:00 2001 From: Ole Christian Eidheim Date: Mon, 5 Dec 2016 13:16:39 +0100 Subject: [PATCH] Fixed Crypto::Base64::encode for newer OpenSSL versions --- crypto.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crypto.hpp b/crypto.hpp index b29baa3d..425c1f8d 100644 --- a/crypto.hpp +++ b/crypto.hpp @@ -24,14 +24,14 @@ namespace SimpleWeb { template void encode(const type& ascii, type& base64) { BIO *bio, *b64; - BUF_MEM *bptr; + BUF_MEM *bptr=BUF_MEM_new(); b64 = BIO_new(BIO_f_base64()); BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL); bio = BIO_new(BIO_s_mem()); BIO_push(b64, bio); - BIO_get_mem_ptr(b64, &bptr); - + BIO_set_mem_buf(b64, bptr, BIO_CLOSE); + //Write directly to base64-buffer to avoid copy int base64_length=static_cast(round(4*ceil((double)ascii.size()/3.0))); base64.resize(base64_length);