aboutsummaryrefslogtreecommitdiffstats
path: root/src/init.c (unfollow)
Commit message (Collapse)AuthorFilesLines
2021-05-20core: Make gpgrt_free robust against legacy free implementations.Werner Koch1-0/+12
* src/init.c (_gpgrt_free): Shortcut NULL and save ERRNO. Signed-off-by: Werner Koch <[email protected]>
2020-03-03core: New function gpgrt_reallocarray.Werner Koch1-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]>
2019-01-04core: New functions gpgrt_abort and gpgrt_add_emergency_cleanup.Werner Koch1-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]>
2018-11-13Fix typo in the annotation.NIIBE Yutaka1-1/+1
* src/init.c [DLL_EXPORT] (DllMain): Fix typo. Signed-off-by: NIIBE Yutaka <[email protected]>
2018-05-01core,w32: Avoid recursive use of npth_unprotect.Werner Koch1-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]>
2018-02-21doc: Typo fixes.Werner Koch1-1/+1
--
2017-11-17core: New API functions gpgrt_strdup and gpgrt_strconcat.Werner Koch1-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]>
2017-11-17core: New API functions gpgrt_malloc, gpgrt_calloc, and gpgrt_realloc.Werner Koch1-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]>
2017-07-05doc: Typo fixWerner Koch1-1/+1
--
2017-02-28Improve tracing of estream.Werner Koch1-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]>
2017-02-26Add a tracing framework.Werner Koch1-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.
2017-02-26Rename internal functions of estream.Werner Koch1-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]>
2016-02-08Convert http links to https where possible in the source.Daniel Kahn Gillmor1-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
2015-11-19Avoid 'malloc' corner case.Justus Winter1-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]>
2015-04-10w32: Remove compiler warnings.Werner Koch1-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.
2014-08-26Add gpgrt_set_alloc_func.Werner Koch1-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.
2014-08-26Export missing init functions.Werner Koch1-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.
2014-08-25Replace locking code in estream functions.Werner Koch1-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.
2014-08-25Implement symbol visibility.Werner Koch1-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.
2014-08-25Fix some minor estream things.Werner Koch1-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.
2010-10-31s/abort/TerminateProcess/Werner Koch1-1/+2
2010-10-292010-10-29 Marcus Brinkmann <[email protected]>Marcus Brinkmann1-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.
2010-10-28Add some code to allow building with MSC.Werner Koch1-0/+4
2010-10-20Add comment.Werner Koch1-0/+4
2010-10-20Fix for W32CE.Werner Koch1-0/+21
2010-09-16Fix initialization of static libsWerner Koch1-0/+1
2010-07-21Add gpg_err_deinitlibgpg-error-1.9Werner Koch1-4/+54
Prepare a new release.
2010-04-14MAp some W32 error codes.Werner Koch1-6/+5
2010-01-21Finished W32CE support.Werner Koch1-168/+65
2010-01-18Fix w32ce strerror.Werner Koch1-6/+83
Fix non-w32ce dependency problem.
2010-01-18Add some code to build nativley under WindowsCE - not finished.Werner Koch1-53/+203
2006-07-042006-07-04 Marcus Brinkmann <[email protected]>Marcus Brinkmann1-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-292006-05-29 Marcus Brinkmann <[email protected]>Marcus Brinkmann1-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-232005-10-23 Marcus Brinkmann <[email protected]>Marcus Brinkmann1-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.