pgsql: Fix allocation logic of cryptohash context data with OpenSSL

Поиск
Список
Период
Сортировка
От Michael Paquier
Тема pgsql: Fix allocation logic of cryptohash context data with OpenSSL
Дата
Msg-id E1kxK5d-0004h5-GI@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Fix allocation logic of cryptohash context data with OpenSSL

The allocation of the cryptohash context data when building with OpenSSL
was happening in the memory context of the caller of
pg_cryptohash_create(), which could lead to issues with resowner cleanup
if cascading resources are cleaned up on an error.  Like other
facilities using resowners, move the base allocation to TopMemoryContext
to ensure a correct cleanup on failure.

The resulting code gets simpler with this commit as the context data is
now hold by a unique opaque pointer, so as there is only one single
allocation done in TopMemoryContext.

After discussion, also change the cryptohash subroutines to return an
error if the caller provides NULL for the context data to ease error
detection on OOM.

Author: Heikki Linnakangas
Discussion: https://postgr.es/m/X9xbuEoiU3dlImfa@paquier.xyz

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/55fe26a4b580b17d721c5accb842cc6a08295273

Modified Files
--------------
src/common/cryptohash.c          | 111 ++++++++++++++++-----------------------
src/common/cryptohash_openssl.c  |  86 ++++++++++++------------------
src/include/common/cryptohash.h  |   8 +--
src/tools/pgindent/typedefs.list |   1 -
4 files changed, 81 insertions(+), 125 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Improve timeout.c's handling of repeated timeout set/cancel.
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Fix bogus link in test comments.