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 <firstname.lastname@example.org>