From: Marko Kreen <markokr@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Stefan Kaltenbrunner <stefan@kaltenbrunner.cc>
Cc: Postgres-Bugs <pgsql-bugs@postgresql.org>
Subject: Re: pgcrypto decrypt_iv() issue
Date: Fri, 27 Jan 2012 19:43:16 +0200
Message-ID: <20120127174316.GA5955@gmail.com> (raw)
In-Reply-To: <10056.1327684401@sss.pgh.pa.us>
References: <4F1DB7BF.60304@kaltenbrunner.cc>
<4F1F23E8.80100@kaltenbrunner.cc>
<23889.1327646231@sss.pgh.pa.us>
<20120127152056.GA4107@gmail.com>
<10056.1327684401@sss.pgh.pa.us>
On Fri, Jan 27, 2012 at 12:13:21PM -0500, Tom Lane wrote:
> Marko Kreen <markokr@gmail.com> writes:
> > pgcrypto.c is easily fixable and internal.c has proper checks.
> > But openssl.c does not. And I have a bigger openssl.c cleanup
> > pending. So I would prefer to add missing checks to cleaned-up
> > openssl.c and post them together (soonish).
>
> > But I'm bit unclear about fate of /contrib cleanup patches vs. 9.2,
> > so if they won't get in, it's ok to apply quick fixes to current tree,
> > it won't inconvinience me much.
>
> I think we should fix and back-patch these two specific bugs. The
> openssl.c change sounds like it might be something for HEAD only.
Now I looked more in-depth and seems my comments were off - error
detection for encrypt()/decrypt() happens in px.c not in
internal.c/openssl.c. Latter ones simply validate internal APIs.
So attached patch should be enough to fix the issue.
And it should be quite backportable.
--
marko
Attachments:encrypt_iv.diff (text/x-diff, 924B) downloaddiff --git a/contrib/pgcrypto/pgcrypto.c b/contrib/pgcrypto/pgcrypto.cindex c758853..a441ca7 100644--- a/contrib/pgcrypto/pgcrypto.c+++ b/contrib/pgcrypto/pgcrypto.c@@ -341,8 +341,8 @@ pg_encrypt_iv(PG_FUNCTION_ARGS)
err = px_combo_init(c, (uint8 *) VARDATA(key), klen,
(uint8 *) VARDATA(iv), ivlen);
if (!err)
- px_combo_encrypt(c, (uint8 *) VARDATA(data), dlen,- (uint8 *) VARDATA(res), &rlen);+ err = px_combo_encrypt(c, (uint8 *) VARDATA(data), dlen,+ (uint8 *) VARDATA(res), &rlen);
px_combo_free(c);
@@ -395,8 +395,8 @@ pg_decrypt_iv(PG_FUNCTION_ARGS)
err = px_combo_init(c, (uint8 *) VARDATA(key), klen,
(uint8 *) VARDATA(iv), ivlen);
if (!err)
- px_combo_decrypt(c, (uint8 *) VARDATA(data), dlen,- (uint8 *) VARDATA(res), &rlen);+ err = px_combo_decrypt(c, (uint8 *) VARDATA(data), dlen,+ (uint8 *) VARDATA(res), &rlen);
px_combo_free(c);
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: markokr@gmail.com, tgl@sss.pgh.pa.us, stefan@kaltenbrunner.cc
Subject: Re: pgcrypto decrypt_iv() issue
In-Reply-To: <20120127174316.GA5955@gmail.com>
References: <4F1DB7BF.60304@kaltenbrunner.cc> <4F1F23E8.80100@kaltenbrunner.cc> <23889.1327646231@sss.pgh.pa.us> <20120127152056.GA4107@gmail.com> <10056.1327684401@sss.pgh.pa.us> <20120127174316.GA5955@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox