aboutsummaryrefslogtreecommitdiffstats
path: root/src/init.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* core: Make gpgrt_free robust against legacy free implementations.Werner Koch2021-05-201-0/+12
| | | | | | * src/init.c (_gpgrt_free): Shortcut NULL and save ERRNO. Signed-off-by: Werner Koch <[email protected]>
* core: New function gpgrt_reallocarray.Werner Koch2020-03-031-0/+49
| | | | | | | | | | | | | | | | | * src/init.c (_gpgrt_reallocarray): New. * src/visibility.c (gpgrt_reallocarray): New. * src/gpg-error.vers, src/gpg-error.def.in: Add new function. * src/gpg-error.h.in: Add new interface. * tests/t-malloc.c: New. * tests/Makefile.am (TESTS): Add new test. -- Note that this function is different from the glibc function because it has an extra parameter which allows to clear the new elements. A realloc after a calloc with forgotten memset after it is a common source of error, thus we introduce this slightly different function. Signed-off-by: Werner Koch <[email protected]>
* core: New functions gpgrt_abort and gpgrt_add_emergency_cleanup.Werner Koch2019-01-041-2/+77
| | | | | | | | | | | | | | | | | | | | | | | | | | * 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 <[email protected]>
* Fix typo in the annotation.NIIBE Yutaka2018-11-131-1/+1
| | | | | | * src/init.c [DLL_EXPORT] (DllMain): Fix typo. Signed-off-by: NIIBE Yutaka <[email protected]>
* core,w32: Avoid recursive use of npth_unprotect.Werner Koch2018-05-011-1/+5
| | | | | | | | | | | | | | | | | | | | * src/w32-estream.c (reader): Use standard free. (writer): Ditto. -- There are two errors: The minor one is that we allocated with calloc but released with _gpgrt_free. The major one is the recursive use of npth_unprotect due to the syscall_clamp mechanism: 1. Around the call to _gpgrt_w32_poll 2. By gpgrt_lock_lock on behalf of a the custom allocation handler in the worker threads at their _gpgrt_free. This problem was exhibited by GnuPG's dirmngr component. GnuPG-bug-id: 3937 Signed-off-by: Werner Koch <[email protected]>
* doc: Typo fixes.Werner Koch2018-02-211-1/+1
| | | | --
* core: New API functions gpgrt_strdup and gpgrt_strconcat.Werner Koch2017-11-171-0/+64
| | | | | | | | | | | | | | | * src/visibility.c (gpgrt_strdup): New API fucntion. (gpgrt_strconcat): New API fucntion. * src/visibility.h: Add corresponding macros. * src/gpg-error.def.in: Add them. * src/gpg-error.vers: Add them. * src/gpgrt-int.h (DIM): New macro. * src/init.c (_gpgrt_strdup): New. (_gpgrt_strconcat_core): New. (_gpgrt_strconcat): New. -- Signed-off-by: Werner Koch <[email protected]>
* core: New API functions gpgrt_malloc, gpgrt_calloc, and gpgrt_realloc.Werner Koch2017-11-171-0/+21
| | | | | | | | | | | | | * src/visibility.c (gpgrt_realloc): New API function. (gpgrt_malloc): New API function. (gpgrt_calloc): New API function. * src/visibility.h: Add corresponding macros. * src/gpg-error.def.in: Add them. * src/gpg-error.vers: Add them. * src/init.c (_gpgrt_calloc): New. * src/gpg-error.h.in: Add prototypes. Signed-off-by: Werner Koch <[email protected]>
* doc: Typo fixWerner Koch2017-07-051-1/+1
| | | | --
* Improve tracing of estream.Werner Koch2017-02-281-25/+49
| | | | | | | | | | | | * src/gpgrt-int.h (trace_errno): Add new parameter. Adjust all users. * src/init.c (trace_fp, trace_with_errno, trace_missing_lf) (trace_prefix_done): New vars. (_gpgrt_internal_trace_begin): Add arg WITH_ERRNO. Open a trace file on first use. Init new vars. (print_internal_trace_prefix): New. * src/estream.c, src/w32-estream.c: Improve tracing. Signed-off-by: Werner Koch <[email protected]>
* Add a tracing framework.Werner Koch2017-02-261-0/+77
| | | | | | | | | | | | | | | | | | | | * src/init.c (trace_save_errno, trace_arg_module) (trace_arg_file, trace_arg_line): New module vars. (do_internal_trace): New. (_gpgrt_internal_trace_printf): New. (_gpgrt_internal_trace): New. (_gpgrt_internal_trace_errno): New. (_gpgrt_internal_trace_end): New. * src/gpgrt-int.h (trace): New macro. (trace_errno): New macro. (trace_start): New macro. (trace_append): New macro. (trace_finish): New macro. -- We want to be abale to use libgpg-error also with pre-c99 compilers and thus we can use the __VA_ARGS__ but resort to the common macro trick.
* Rename internal functions of estream.Werner Koch2017-02-261-1/+1
| | | | | | | | | | | | | | | | | | | | * src/estream.c (_gpgrt_es_init): Rename to _gpgrt_estream_init. (es_fill): Rename to fill_stream. (es_fflush): Rename to flush_stream. (es_deinitialize): Rename to deinit_stream_obj. (es_create): Rename to create_stream (es_read_nbf): Rename to do_read_nbf. (es_read_lbf): Rename to do_read_lbf. (es_read_fbf): Rename to do_read_fbf. (es_peek): Rename to peek_stream. (es_skip): Rename to skip_stream. (es_print): Rename to do_print_stream. -- The use of the "es_" was confusing. Avoid that. Signed-off-by: Werner Koch <[email protected]>
* Convert http links to https where possible in the source.Daniel Kahn Gillmor2016-02-081-1/+1
| | | | | | | | | | | | | | | | -- * use https for bug reporting * in comments and docs, use https to refer to: - www.gnu.org - creativecommons.org - translationproject.org - mail.gnome.org - www.perl.org - www.ctan.org - www.cl.cam.ac.uk - www.ntg.nl - cygwin.com - www.ethnologue.com
* Avoid 'malloc' corner case.Justus Winter2015-11-191-3/+3
| | | | | | | | | | | | | * src/init.c (_gpgrt_realloc): Avoid calling 'malloc(0)'. -- Previously, if '_gpgrt_realloc' was called with both A and N being zero, malloc is invoked with a size of zero. This happens e.g. when calling '_gpgrt_free' with a NULL pointer, which is supposed to be a no-op. Found using the Clang Static Analyzer. Signed-off-by: Justus Winter <[email protected]>
* w32: Remove compiler warnings.Werner Koch2015-04-101-80/+13
| | | | | | | | | | | | | | * src/Makefile.am (pre_mkheader_cmds): Avoid make diagnostic about failed but ignored command. This confuses Emacs' compiler job parser. * tests/t-lock.c [W32]: Include time.h. * src/init.c: Reorganize Windows only code. (wchar_to_utf8, utf8_to_wchar): Remove unused functions. (_gpg_err_set_errno): Use only one copy for all platforms. -- Note that there is a still a problem for W64 pertaining to the use of an int to store a HANDLE. This will be fixed when we add a full abstraction layer for Windows file objects.
* Add gpgrt_set_alloc_func.Werner Koch2014-08-261-0/+57
| | | | | | | | | | | | | * src/visibility.c (gpgrt_set_alloc_func): New. * configure.ac (_ESTREAM_PRINTF_REALLOC): Define. (_ESTREAM_PRINTF_EXTRA_INCLUDE): Define. * src/estream.c (mem_alloc, mem_realloc, mem_free): Simplify. (_gpgrt_free): Remove. * src/init.c (custom_realloc): New var. (_gpgrt_set_alloc_func): New. (_gpgrt_realloc, _gpgrt_malloc, _gpgrt_free): New. * src/visibility.h (gpg_err_deinit): Mark as visible.
* Export missing init functions.Werner Koch2014-08-261-2/+2
| | | | | | | | | | | | | | | | | * src/gpg-error.h.in (gpgrt_init): New macro. (gpgrt_check_version): New prototype. * src/init.c (_gpg_err_init): Rename from gpg_err_init. (_gpg_err_deinit): Rename from gpg_err_deinit. * src/visibility.c (gpg_err_init): New. (gpg_err_deinit): New. (gpgrt_check_version): New. * src/gpg-error.vers (gpg_err_init, gpg_err_deinit): Add missing symbols. (gpgrt_check_version): New. * src/gpg-error.def.in (gpg_err_init, gpg_err_deinit): Add missing symbols. (gpgrt_check_version): New. * src/gpg-error.c (main): Use gpgrt_init macro.
* Replace locking code in estream functions.Werner Koch2014-08-251-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | * src/posix-lock.c: Add weak program for pthread_mutex_trylock. (_gpgrt_lock_trylock): New. * src/w32-lock.c (_gpgrt_lock_init): Add missing return statement. (_gpgrt_lock_trylock): New. * src/visibility.c (gpgrt_set_syscall_clamp): New. (gpgrt_lock_trylock): New. (gpgrt_vsnprintf): Fix symbol name. * src/init.c (DllMain): Mark unused arg. * src/estream.c: Replace npth mutexes by our own locks. Replace yeild macro by _gpgrt_yield. (pre_syscall_func, post_syscall_func): New. (do_deinit): Clear both new vars. (es_func_fd_read, es_func_fd_write): Call pre and post syscall functions instead of the former SYSCALL macros. (es_func_w32_read, es_func_w32_write): Ditto. (es_func_fd_seek, es_func_w32_seek, es_func_fp_read) (es_func_fp_write, es_func_fp_seek, es_func_fp_destroy): Bracket syscalls with the pre- and post-syscall fucntions. (do_npth_read, do_npth_write): Remove. (_gpgrt_es_init): Remove call to mutex init. It is now statically initialized. (_gpgrt_set_syscall_clamp): New. (es_create): Destroy stream lock on error. (do_close): Destroy stream lock.
* Implement symbol visibility.Werner Koch2014-08-251-5/+3
| | | | | | | | | | | | | * configure.ac: New option --enable-ld-version-script. (GPGRT_USE_VISIBILITY): New ac_define. (HAVE_LD_VERSION_SCRIPT): New am_conditional. * src/gpg-error.vers: New. * src/gpgrt-int.h: New. * src/visibility.c, src/visibility.h: New. Lot of changes to symbold names. -- This is only doe for the old API. The estream API needs to be added.
* Fix some minor estream things.Werner Koch2014-08-251-11/+13
| | | | | | | * m4/estream.m4: Check for memrchr. * src/estream.c (memrchr) [!HAVE_MEMRCHR]: New. * src/init.c: Include estream.h (real_init): Init estream.
* s/abort/TerminateProcess/Werner Koch2010-10-311-1/+2
|
* 2010-10-29 Marcus Brinkmann <[email protected]>Marcus Brinkmann2010-10-291-0/+6
| | | | | | | | | | | | * src/w32-gettext.c: Guard include of <sys/types.h>. Do not include <sys/stat.h>. (CreateFileA) [HAVE_W32CE_SYSTEM]: New wrapper function. (load_domain): Use native Windows API. * src/init.c (TLS_OUT_OF_INDEXES) [HAVE_W32CE_SYSTEM, !TLS_OUT_OF_INDEXES]: Define it. (abort) [!__MINGW32CE__]: Define it.
* Add some code to allow building with MSC.Werner Koch2010-10-281-0/+4
|
* Add comment.Werner Koch2010-10-201-0/+4
|
* Fix for W32CE.Werner Koch2010-10-201-0/+21
|
* Fix initialization of static libsWerner Koch2010-09-161-0/+1
|
* Add gpg_err_deinitlibgpg-error-1.9Werner Koch2010-07-211-4/+54
| | | | | Prepare a new release.
* MAp some W32 error codes.Werner Koch2010-04-141-6/+5
|
* Finished W32CE support.Werner Koch2010-01-211-168/+65
|
* Fix w32ce strerror.Werner Koch2010-01-181-6/+83
| | | | | Fix non-w32ce dependency problem.
* Add some code to build nativley under WindowsCE - not finished.Werner Koch2010-01-181-53/+203
|
* 2006-07-04 Marcus Brinkmann <[email protected]>Marcus Brinkmann2006-07-041-2/+2
| | | | | | | * src/init.c (get_locale_dir): Return NULL instead of garbage. * src/gpg-error.c (get_locale_dir): Likewise. Submitted by Simon Josefsson <[email protected]>.
* 2006-05-29 Marcus Brinkmann <[email protected]>Marcus Brinkmann2006-05-291-0/+2
| | | | | | | | * src/init.c (gpg_err_init) [!ENABLE_NLS]: Do not initialize the locale. * src/gpg-error.c (i18n_init) [!ENABLE_NLS]: Likewise. Patch submitted by Nils Durner <[email protected]>.
* 2005-10-23 Marcus Brinkmann <[email protected]>Marcus Brinkmann2005-10-231-0/+224
* src/Makefile.am (libgpg_error_la_SOURCES): Add init.c. * src/init.c: New file. * src/gpg-error.h.in (gpg_error_init): New function. * src/gpg-error.def: Add gpg_err_init. * src/gpg-error.c: Remove SIMPLE_GETTEXT stuff. (i18n_init): Don't bind text domain. (main): Call gpg_err_init.