From: | Heikki Linnakangas <hlinnaka(at)iki(dot)fi> |
---|---|
To: | Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Asif Naeem <anaeem(dot)it(at)gmail(dot)com> |
Cc: | Andreas Karlsson <andreas(at)proxel(dot)se>, Andres Freund <andres(at)anarazel(dot)de>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: pgcrypto compilation error due to stack-allocated EVP_CIPHER_CTX |
Date: | 2016-12-12 09:17:32 |
Message-ID: | 7a4640ef-20f7-cb02-cf27-3dfa68347b25@iki.fi |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 12/12/2016 07:18 AM, Michael Paquier wrote:
> On Fri, Dec 9, 2016 at 10:22 AM, Michael Paquier
> <michael(dot)paquier(at)gmail(dot)com> wrote:
>> Thanks for looking at the patch. Looking forward to hearing more!
>
> Here is an updated patch based on which reviews should be done. I have
> fixed the issue you have reported, and upon additional lookup I have
> noticed that returning -1 when failing on EVP_CIPHER_CTX_new() in
> px_find_cipher() is dead wrong. The error code should be
> PXE_CIPHER_INIT.
> @@ -307,17 +360,18 @@ gen_ossl_decrypt(PX_Cipher *c, const uint8 *data, unsigned dlen,
>
> if (!od->init)
> {
> - EVP_CIPHER_CTX_init(&od->evp_ctx);
> - if (!EVP_DecryptInit_ex(&od->evp_ctx, od->evp_ciph, NULL, NULL, NULL))
> + if (!EVP_CIPHER_CTX_cleanup(od->evp_ctx))
> + return PXE_CIPHER_INIT;
> + if (!EVP_DecryptInit_ex(od->evp_ctx, od->evp_ciph, NULL, NULL, NULL))
> return PXE_CIPHER_INIT;
> - if (!EVP_CIPHER_CTX_set_key_length(&od->evp_ctx, od->klen))
> + if (!EVP_CIPHER_CTX_set_key_length(od->evp_ctx, od->klen))
> return PXE_CIPHER_INIT;
> - if (!EVP_DecryptInit_ex(&od->evp_ctx, NULL, NULL, od->key, od->iv))
> + if (!EVP_DecryptInit_ex(od->evp_ctx, NULL, NULL, od->key, od->iv))
> return PXE_CIPHER_INIT;
> od->init = true;
> }
The EVP_CIPHER_CTX_cleanup() call seems superfluous. We know that the
context isn't initialized yet, so no need to clean it up.
Removed that, did some further cosmetic changes, and pushed. I renamed a
bunch variables and structs, so that they are more consistent with the
similar digest stuff.
Thanks!
- Heikki
From | Date | Subject | |
---|---|---|---|
Next Message | Gilles Darold | 2016-12-12 09:31:09 | Re: Patch to implement pg_current_logfile() function |
Previous Message | Rafa de la Torre | 2016-12-12 09:10:21 | Re: Fix for segfault in plpython's exception handling |