Skip to content

Commit

Permalink
Merge branch '2.3-xb-bug1678947' into 2.4-xb-bug1678947
Browse files Browse the repository at this point in the history
* 2.3-xb-bug1678947:
  Bug 1678947: Build failure on Debian Stretch
  • Loading branch information
gl-sergei committed Apr 19, 2017
2 parents d00b900 + 8853f2d commit 2cb5481
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 18 deletions.
30 changes: 14 additions & 16 deletions mysys_ssl/my_aes_openssl.cc
Expand Up @@ -122,7 +122,7 @@ int my_aes_encrypt(const unsigned char *source, uint32 source_length,
enum my_aes_opmode mode, const unsigned char *iv,
bool padding)
{
EVP_CIPHER_CTX ctx;
EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new();
const EVP_CIPHER *cipher= aes_evp_type(mode);
int u_len, f_len;
/* The real key to be used for encryption */
Expand All @@ -132,23 +132,23 @@ int my_aes_encrypt(const unsigned char *source, uint32 source_length,
if (!cipher || (EVP_CIPHER_iv_length(cipher) > 0 && !iv))
return MY_AES_BAD_DATA;

if (!EVP_EncryptInit(&ctx, cipher, rkey, iv))
if (!EVP_EncryptInit(ctx, cipher, rkey, iv))
goto aes_error; /* Error */
if (!EVP_CIPHER_CTX_set_padding(&ctx, padding))
if (!EVP_CIPHER_CTX_set_padding(ctx, padding))
goto aes_error; /* Error */
if (!EVP_EncryptUpdate(&ctx, dest, &u_len, source, source_length))
if (!EVP_EncryptUpdate(ctx, dest, &u_len, source, source_length))
goto aes_error; /* Error */

if (!EVP_EncryptFinal(&ctx, dest + u_len, &f_len))
if (!EVP_EncryptFinal(ctx, dest + u_len, &f_len))
goto aes_error; /* Error */

EVP_CIPHER_CTX_cleanup(&ctx);
EVP_CIPHER_CTX_free(ctx);
return u_len + f_len;

aes_error:
/* need to explicitly clean up the error if we want to ignore it */
ERR_clear_error();
EVP_CIPHER_CTX_cleanup(&ctx);
EVP_CIPHER_CTX_free(ctx);
return MY_AES_BAD_DATA;
}

Expand All @@ -159,7 +159,7 @@ int my_aes_decrypt(const unsigned char *source, uint32 source_length,
bool padding)
{

EVP_CIPHER_CTX ctx;
EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new();
const EVP_CIPHER *cipher= aes_evp_type(mode);
int u_len, f_len;

Expand All @@ -170,24 +170,22 @@ int my_aes_decrypt(const unsigned char *source, uint32 source_length,
if (!cipher || (EVP_CIPHER_iv_length(cipher) > 0 && !iv))
return MY_AES_BAD_DATA;

EVP_CIPHER_CTX_init(&ctx);

if (!EVP_DecryptInit(&ctx, aes_evp_type(mode), rkey, iv))
if (!EVP_DecryptInit(ctx, aes_evp_type(mode), rkey, iv))
goto aes_error; /* Error */
if (!EVP_CIPHER_CTX_set_padding(&ctx, padding))
if (!EVP_CIPHER_CTX_set_padding(ctx, padding))
goto aes_error; /* Error */
if (!EVP_DecryptUpdate(&ctx, dest, &u_len, source, source_length))
if (!EVP_DecryptUpdate(ctx, dest, &u_len, source, source_length))
goto aes_error; /* Error */
if (!EVP_DecryptFinal_ex(&ctx, dest + u_len, &f_len))
if (!EVP_DecryptFinal_ex(ctx, dest + u_len, &f_len))
goto aes_error; /* Error */

EVP_CIPHER_CTX_cleanup(&ctx);
EVP_CIPHER_CTX_free(ctx);
return u_len + f_len;

aes_error:
/* need to explicitly clean up the error if we want to ignore it */
ERR_clear_error();
EVP_CIPHER_CTX_cleanup(&ctx);
EVP_CIPHER_CTX_free(ctx);
return MY_AES_BAD_DATA;
}

Expand Down
4 changes: 4 additions & 0 deletions sql/mysqld.cc
Expand Up @@ -3345,7 +3345,11 @@ static int init_ssl()
{
#ifdef HAVE_OPENSSL
#ifndef HAVE_YASSL
#if OPENSSL_VERSION_NUMBER >= 0x10100005L
OPENSSL_malloc_init();
#else
CRYPTO_malloc_init();
#endif
#endif
ssl_start();
#if !defined(EMBEDDED_LIBRARY) || defined(XTRABACKUP)
Expand Down
18 changes: 16 additions & 2 deletions vio/viosslfactories.c
Expand Up @@ -118,16 +118,30 @@ static unsigned char dh2048_g[]={

static DH *get_dh2048(void)
{
DH *dh;
if ((dh=DH_new()))
DH *dh = DH_new();

if (dh != NULL)
{
#if OPENSSL_VERSION_NUMBER >= 0x10100005L
BIGNUM *p, *g;
p = BN_bin2bn(dh2048_p, sizeof(dh2048_p), NULL);
g = BN_bin2bn(dh2048_g, sizeof(dh2048_g), NULL);
if (p == NULL || g == NULL || !DH_set0_pqg(dh, p, NULL, g))
{
DH_free(dh);
BN_free(p);
BN_free(g);
dh=0;
}
#else
dh->p=BN_bin2bn(dh2048_p,sizeof(dh2048_p),NULL);
dh->g=BN_bin2bn(dh2048_g,sizeof(dh2048_g),NULL);
if (! dh->p || ! dh->g)
{
DH_free(dh);
dh=0;
}
#endif
}
return(dh);
}
Expand Down

0 comments on commit 2cb5481

Please sign in to comment.