Robert Haas wrote:
> I wrote:
>> src, dst and ctx are created respectively from mbuf_create_from_data,
>> mbuf_create and pgp_init which never return NULL and they are palloc'd
>> all the time. I think that we could simplify things with the patch
>> attached, note that I added an assertion for correctness but I don't
>> really think that it is much necessary.
>
> Yeah, I'd drop the assertion. Also, how about changing things around
> slightly so that we lose the goto-label construct? There's only one
> goto, and its only about 6 lines before the label, so we could just
> flip the sense of the if-test and put the code that gets skipped
> inside the if-block.
Good idea. This gives the patch attached then.
Regards,
--
Michael
*** a/contrib/pgcrypto/pgp-pgsql.c
--- b/contrib/pgcrypto/pgp-pgsql.c
***************
*** 575,609 **** decrypt_internal(int is_pubenc, int need_text, text *data,
err = pgp_set_symkey(ctx, (uint8 *) VARDATA(key),
VARSIZE(key) - VARHDRSZ);
! /*
! * decrypt
! */
if (err >= 0)
err = pgp_decrypt(ctx, src, dst);
! /*
! * failed?
! */
! if (err < 0)
! goto out;
!
! if (ex.expect)
! check_expect(ctx, &ex);
! /* remember the setting */
! got_unicode = pgp_get_unicode_mode(ctx);
! out:
! if (src)
! mbuf_free(src);
! if (ctx)
! pgp_free(ctx);
if (err)
{
px_set_debug_handler(NULL);
! if (dst)
! mbuf_free(dst);
ereport(ERROR,
(errcode(ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION),
errmsg("%s", px_strerror(err))));
--- 575,599 ----
err = pgp_set_symkey(ctx, (uint8 *) VARDATA(key),
VARSIZE(key) - VARHDRSZ);
! /* decrypt */
if (err >= 0)
+ {
err = pgp_decrypt(ctx, src, dst);
! if (ex.expect)
! check_expect(ctx, &ex);
! /* remember the setting */
! got_unicode = pgp_get_unicode_mode(ctx);
! }
! mbuf_free(src);
! pgp_free(ctx);
if (err)
{
px_set_debug_handler(NULL);
! mbuf_free(dst);
ereport(ERROR,
(errcode(ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION),
errmsg("%s", px_strerror(err))));
--
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers