Re: Fix error handling in be_tls_open_server()

Daniel Gustafsson <daniel@yesql.se>

From: Daniel Gustafsson <daniel@yesql.se>
To: Sergey Shinderuk <s.shinderuk@postgrespro.ru>
Cc: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2023-08-24T08:38:24Z
Lists: pgsql-hackers
> On 24 Aug 2023, at 10:11, Sergey Shinderuk <s.shinderuk@postgrespro.ru> wrote:
> 
> On 23.08.2023 16:23, Daniel Gustafsson wrote:
>>> On 1 Aug 2023, at 16:44, Sergey Shinderuk <s.shinderuk@postgrespro.ru> wrote:
>>> A static analyzer reported a possible pfree(NULL) in be_tls_open_server().
>> This has the smell of a theoretical problem, I can't really imagine a
>> certificate where which would produce this.  Have you been able to trigger it?
> 
> I triggered a crash by generating a certificate without a CN and forcing malloc to return NULL when called from X509_NAME_print_ex or BIO_get_mem_ptr with gdb.

Can you extend the patch with that certificate and a test using it?  The
certificates are generated from config files kept in the repo in src/test/ssl
in order to be reproducible.

--
Daniel Gustafsson




Commits

  1. Avoid potential pfree on NULL on OpenSSL errors