Control: tags -1 + patch
Control: forwarded -1 https://github.com/boxbackup/boxbackup/issues/16
The above patch changes a single object into a pointer, and changes
init/cleanup into new/free.
Chris.
commit 9d2bf90676206957a502e9ec1c3cfe4f4b40b0cc
Author: Chris West (Faux)
Date: Thu Jun 1 17:01:16 2017 +
dynamically allocate EVP_CTX
diff --git a/boxbackup-0.11.1~r2837/debian/control b/boxbackup-0.11.1~r2837/debian/control
index 5cbdba6..d422125 100644
--- a/boxbackup-0.11.1~r2837/debian/control
+++ b/boxbackup-0.11.1~r2837/debian/control
@@ -12,7 +12,7 @@ Build-Depends:
docbook-xsl,
libdb-dev (>= 4.7),
libedit-dev,
- libssl1.0-dev,
+ libssl-dev,
libtest-lwp-useragent-perl,
xsltproc,
zlib1g-dev
diff --git a/boxbackup-0.11.1~r2837/lib/crypto/CipherContext.cpp b/boxbackup-0.11.1~r2837/lib/crypto/CipherContext.cpp
index e5cd9b0..f23317f 100644
--- a/boxbackup-0.11.1~r2837/lib/crypto/CipherContext.cpp
+++ b/boxbackup-0.11.1~r2837/lib/crypto/CipherContext.cpp
@@ -49,7 +49,7 @@ CipherContext::~CipherContext()
if(mInitialised)
{
// Clean up
- EVP_CIPHER_CTX_cleanup(&ctx);
+ EVP_CIPHER_CTX_free(ctx);
mInitialised = false;
}
#ifdef HAVE_OLD_SSL
@@ -84,9 +84,9 @@ void CipherContext::Init(CipherContext::CipherFunction Function, const CipherDes
// Initialise the cipher
#ifndef HAVE_OLD_SSL
- EVP_CIPHER_CTX_init(&ctx); // no error return code, even though the docs says it does
+ ctx = EVP_CIPHER_CTX_new();
- if(EVP_CipherInit_ex(&ctx, rDescription.GetCipher(), NULL, NULL, NULL, Function) != 1)
+ if(EVP_CipherInit_ex(ctx, rDescription.GetCipher(), NULL, NULL, NULL, Function) != 1)
#else
// Store function for later
mFunction = Function;
@@ -102,19 +102,19 @@ void CipherContext::Init(CipherContext::CipherFunction Function, const CipherDes
{
#ifndef HAVE_OLD_SSL
// Let the description set up everything else
- rDescription.SetupParameters(&ctx);
+ rDescription.SetupParameters(ctx);
#else
// With the old version, a copy needs to be taken first.
mpDescription = rDescription.Clone();
// Mark it as not a leak, otherwise static cipher contexts
// cause spurious memory leaks to be reported
MEMLEAKFINDER_NOT_A_LEAK(mpDescription);
- mpDescription->SetupParameters(&ctx);
+ mpDescription->SetupParameters(ctx);
#endif
}
catch(...)
{
- EVP_CIPHER_CTX_cleanup(&ctx);
+ EVP_CIPHER_CTX_free(ctx);
throw;
}
@@ -135,7 +135,7 @@ void CipherContext::Reset()
if(mInitialised)
{
// Clean up
- EVP_CIPHER_CTX_cleanup(&ctx);
+ EVP_CIPHER_CTX_cleanup(ctx);
mInitialised = false;
}
#ifdef HAVE_OLD_SSL
@@ -172,7 +172,7 @@ void CipherContext::Begin()
}
// Initialise the cipher context again
- if(EVP_CipherInit(&ctx, NULL, NULL, NULL, -1) != 1)
+ if(EVP_CipherInit(ctx, NULL, NULL, NULL, -1) != 1)
{
THROW_EXCEPTION(CipherException, EVPInitFailure)
}
@@ -218,14 +218,14 @@ int CipherContext::Transform(void *pOutBuffer, int OutLength, const void *pInBuf
}
// Check output buffer size
- if(OutLength < (InLength + EVP_CIPHER_CTX_block_size(&ctx)))
+ if(OutLength < (InLength + EVP_CIPHER_CTX_block_size(ctx)))
{
THROW_EXCEPTION(CipherException, OutputBufferTooSmall);
}
// Do the transform
int outLength = OutLength;
- if(EVP_CipherUpdate(&ctx, (unsigned char*)pOutBuffer, &outLength, (unsigned char*)pInBuffer, InLength) != 1)
+ if(EVP_CipherUpdate(ctx, (unsigned char*)pOutBuffer, &outLength, (unsigned char*)pInBuffer, InLength) != 1)
{
THROW_EXCEPTION(CipherException, EVPUpdateFailure)
}
@@ -265,7 +265,7 @@ int CipherContext::Final(void *pOutBuffer, int OutLength)
}
// Check output buffer size
- if(OutLength < (2 * EVP_CIPHER_CTX_block_size(&ctx)))
+ if(OutLength < (2 * EVP_CIPHER_CTX_block_size(ctx)))
{
THROW_EXCEPTION(CipherException, OutputBufferTooSmall);
}
@@ -273,7 +273,7 @@ int CipherContext::Final(void *pOutBuffer, int OutLength)
// Do the transform
int outLength = OutLength;
#ifndef HAVE_OLD_SSL
- if(EVP_CipherFinal_ex(&ctx, (unsigned char*)pOutBuffer, &outLength) != 1)
+ if(EVP_CipherFinal_ex(ctx, (unsigned char*)pOutBuffer, &outLength) != 1)
{
THROW_EXCEPTION(CipherException, EVPFinalFailure)
}
@@ -302,11 +302,11 @@ void CipherContext::OldOpenSSLFinal(unsigned char *Buffer, int &rOutLengthOut)
// Old version needs to use a different form, and then set up the cipher again for next time around
int outLength = rOutLengthOut;
// Have to emulate padding off...
- int blockSize = EVP_CIPHER_CTX_block_size(&ctx);
+ int blockSize = EVP_CIPHER_CTX_block_size(ctx);
if(mPaddingOn)
{
// Just use normal final call
- if(EVP_CipherFinal(&ctx, Buffer, &outLength) != 1)
+ if(EVP_CipherFinal(ctx, Buffer, &outLength) != 1)
{
THROW_EXCEPTION(CipherException, EVPFinalFailure)
}
@@ -319,13 +319,13 @@ void CipherContext::OldOpenSSLFinal(unsigned char *Buffer, int &rOutLengthOut)
{
// NASTY -- fiddling around with internals like this is bad.
// But only way to get this w