Fix Coverity warning about contrib/pgcrypto's mdc_finish().
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 30 Jan 2015 18:04:56 +0000 (13:04 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 30 Jan 2015 18:05:30 +0000 (13:05 -0500)
commita59ee881978a2027dced30053f8ad4cd8e143953
tree5bb7d358f8dcd9f8ae687a32950d9b99fac9de38
parentbd4e2fd97d3db84bd970d6051f775b7ff2af0e9d
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
contrib/pgcrypto/pgp-decrypt.c