From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: wurongxin@xmu.edu.cn
Subject: BUG #16070: A double-free bug in interfaces/libpq/fe-secure-openssl.c
Date: Sun, 20 Oct 2019 08:58:17 +0000
Message-ID: <16070-ffac944519a43c3f@postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 16070
Logged by: rongxin wu
Email address: wurongxin@xmu.edu.cn
PostgreSQL version: 10.10
Operating system: ubuntu 18
Description:
In
https://github.com/postgres/postgres/blob/REL_10_STABLE/src/interfaces/libpq/fe-secure-openssl.c,
at Line 1206, it would call the function "ENGINE_finish" and free
conn->engine. At Line 1207, it would call the function "ENGINE_free" and
free conn->engine again. This would lead to a double free bug. Please read
the following code snippet.
https://github.com/postgres/postgres/blob/REL_10_STABLE/src/interfaces/libpq/fe-secure-openssl.c
896. static int
897. initialize_SSL(PGconn *conn)
898. {
...
1206. ENGINE_finish(conn->engine);
1207. ENGINE_free(conn->engine);
...
int ENGINE_finish(ENGINE *e)
{
...
to_return = engine_unlocked_finish(e, 1);
...
return to_return;
}
int engine_unlocked_finish(ENGINE *e, int unlock_for_handlers)
{
...
if (!engine_free_util(e, 0)) {
ENGINEerr(ENGINE_F_ENGINE_UNLOCKED_FINISH,
ENGINE_R_FINISH_FAILED);
return 0;
}
return to_return;
}
int engine_free_util(ENGINE *e, int not_locked)
{
...
OPENSSL_free(e); // a free wrapper
return 1;
}
int ENGINE_free(ENGINE *e)
{
return engine_free_util(e, 1);
}
Please help to check. Thanks.
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-bugs@postgresql.org
Cc: noreply@postgresql.org, wurongxin@xmu.edu.cn
Subject: Re: BUG #16070: A double-free bug in interfaces/libpq/fe-secure-openssl.c
In-Reply-To: <16070-ffac944519a43c3f@postgresql.org>
References: <16070-ffac944519a43c3f@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