pgsql: Avoid potential pfree on NULL on OpenSSL errors

From: Daniel Gustafsson <dgustafsson(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Avoid potential pfree on NULL on OpenSSL errors
Date: 2023-09-22 09:27:20
Message-ID: E1qjcRT-005HZ4-TE@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Avoid potential pfree on NULL on OpenSSL errors

Guard against the pointer being NULL before pfreeing upon an error
returned from OpenSSL. Also handle errors from X509_NAME_print_ex
which also can return -1 on memory allocation errors.

Backpatch down to v15 where the code was added.

Author: Sergey Shinderuk <s(dot)shinderuk(at)postgrespro(dot)ru>
Discussion: https://postgr.es/m/8db5374d-32e0-6abb-d402-40762511eff2@postgrespro.ru
Backpatch-through: v15

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/9dc85806d8beb1d4b0cc5461cc3a7d2e44c6e782

Modified Files
--------------
src/backend/libpq/be-secure-openssl.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Daniel Gustafsson 2023-09-22 11:40:54 pgsql: Avoid using internal test methods in SSL tests
Previous Message Daniel Gustafsson 2023-09-22 09:27:12 pgsql: Avoid potential pfree on NULL on OpenSSL errors