pgsql: Fix Coverity warning about contrib/pgcrypto's mdc_finish().

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix Coverity warning about contrib/pgcrypto's mdc_finish().
Date: 2015-01-30 18:05:42
Message-ID: E1YHFws-0001V6-Ro@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix Coverity warning about contrib/pgcrypto's mdc_finish().

Coverity points out that mdc_finish returns a pointer to a local buffer
(which of course is gone as soon as the function returns), leaving open
a risk of misbehaviors possibly as bad as a stack overwrite.

In reality, the only possible call site is in process_data_packets()
which does not examine the returned pointer at all. So there's no
live bug, but nonetheless the code is confusing and risky. Refactor
to avoid the issue by letting process_data_packets() call mdc_finish()
directly instead of going through the pullf_read() API.

Although this is only cosmetic, it seems good to back-patch so that
the logic in pgp-decrypt.c stays in sync across all branches.

Marko Kreen

Branch
------
REL9_3_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/f08cf8ad9098bd26a57fabc5ecbfd7d38e6c2cee

Modified Files
--------------
contrib/pgcrypto/pgp-decrypt.c | 49 ++++++++++++++++------------------------
1 file changed, 19 insertions(+), 30 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2015-01-30 18:31:37 pgsql: doc: Remove superfluous table column
Previous Message Robert Haas 2015-01-30 17:58:34 pgsql: Provide a way to supress the "out of memory" error when allocati