core: New functions gpgrt_abort and gpgrt_add_emergency_cleanup.

Authored by werner on Fri, Jan 4, 1:13 PM.

Description

core: New functions gpgrt_abort and gpgrt_add_emergency_cleanup.

* src/init.c (emergency_cleanup_list): New gloabl var.
(_gpgrt_add_emergency_cleanup): New.
(_gpgrt_abort): New. Repalce all calls to abort by this.  Also replace
all assert by either log_assert or a stderr output followed by a
_gpgrt_abort.
(run_emergency_cleanup): New.
* src/visibility.c (gpgrt_add_emergency_cleanup): New public API.
(gpgrt_abort): New public API.

Libgcrypt uses its own assert function which makes sure to terminate
the secure memory. This is safe as log as an assert is triggered
internally in Libgcrypt. GnuPG runs emergency cleanup handlers right
before log_fatal etc to tell Libgcrypt to terminate the secure memory.
With the move of the logging function to gpgrt in gnupg 2.3 this did
not anymore. Thus we now provide a mechanism in gpgrt to do right
that. Eventually Libgcrypt can also make use of this.

What this does not handle are calls to abort or failed asserts in
external libraries or in libc. We can't do anything about it in a
library because a library may not setup signal handlers.

  • Signed-off-by: Werner Koch <wk@gnupg.org>

Details

Committed
wernerFri, Jan 4, 1:13 PM
Parents
rE12349de46d24: estream: Use correct POSIX name THOUSEP.
Branches
Unknown
Tags
Unknown