pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: pgcrypto: Detect errors with EVP calls from OpenSSL
Date: Tue, 08 Dec 2020 06:24:27 +0000
Message-ID: <E1kmWQF-0005aD-Gl@gemulon.postgresql.org> (raw)

pgcrypto: Detect errors with EVP calls from OpenSSL

The following routines are called within pgcrypto when handling digests
but there were no checks for failures:
- EVP_MD_CTX_size (can fail with -1 as of 3.0.0)
- EVP_MD_CTX_block_size (can fail with -1 as of 3.0.0)
- EVP_DigestInit_ex
- EVP_DigestUpdate
- EVP_DigestFinal_ex

A set of elog(ERROR) is added by this commit to detect such failures,
that should never happen except in the event of a processing failure
internal to OpenSSL.

Note that it would be possible to use ERR_reason_error_string() to get
more context about such errors, but these refer mainly to the internals
of OpenSSL, so it is not really obvious how useful that would be.  This
is left out for simplicity.

Per report from Coverity.  Thanks to Tom Lane for the discussion.

Backpatch-through: 9.5

Branch
------
REL_10_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/5ba1df0f14d19a32c69adf97d452726fa6a28e02

Modified Files
--------------
contrib/pgcrypto/openssl.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)



view thread (7+ messages)  latest in thread

Message-ID: <E1kmWQF-0005aD-Gl@gemulon.postgresql.org>
Permalink:  ../E1kmWQF-0005aD-Gl@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1kmWQF-0005aD-Gl@gemulon.postgresql.org

 · 

reply

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-committers@postgresql.org
  Cc: michael@paquier.xyz
  Subject: Re: pgsql: pgcrypto: Detect errors with EVP calls from OpenSSL
  In-Reply-To: <E1kmWQF-0005aD-Gl@gemulon.postgresql.org>
  References: <E1kmWQF-0005aD-Gl@gemulon.postgresql.org>

* 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