| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
| |
* src/estream.c (_gpgrt_poll): Check for malloc error.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
| |
* src/estream.c [HAVE_POLL_H] (_gpgrt_poll): No VLA.
--
Fixes-commit: a21a7de8c2cf986235382e7e04805744f6df116e
Signed-off-by: NIIBE Yutaka <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
| |
* configure.ac: Detect poll.h.
* src/estream.c [HAVE_POLL_H] (_gpgrt_poll): Use poll.
--
Here, we use C99 feature of array declaration with variable.
Signed-off-by: NIIBE Yutaka <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/gpg-error.h.in (gpgrt_string_filter_t): New type.
(gpgrt_fprintf_sf, gpgrt_fprintf_sf_unlocked): New.
* src/gpg-error.vers, src/gpg-error.def.in: Add them.
* src/visibility.c (gpgrt_fprintf_sf): New.
(gpgrt_fprintf_sf_unlocked): New.
* src/estream-printf.c (pr_string): Add and use args sf, sfvalue and
string_no.
(do_format): Add args sf and sfvalue. Keep a string format counter.
(_gpgrt_estream_format): Add args sf and sfvalue. Change all callers
to provide NULL for them.
* src/estream.c (_gpgrt_vfprintf_unlocked, _gpgrt_vfprintf): Add sf
and sfvalue and adjust all callers.
(do_print_stream): Ditto.
* tests/t-printf.c (stream_to_string): New.
(struct sfstate_s): New.
(string_filter): New.
(check_fprintf_sf): New.
(main): Call new test.
--
The actual reason to implement these functions is to enhance the
internal logging function with a filter to sanitized strings so that
control values or other things can be quoted.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/gpg-error.h.in (gpgrt_ftruncate, es_ftruncate): New.
* src/gpg-error.def.in, src/gpg-error.vers: Add gpgrt_ftruncate.
* src/visibility.c (gpgrt_ftruncate): new.
* src/gpgrt-int.h (COOKIE_IOCTL_TRUNCATE): New.
* src/estream.c (func_mem_ioctl): Support new internal IOCTL.
(_gpgrt_ftruncate): New.
--
Right now the ftruncate works only on memory streams. Can easily be
added to other stream times.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
| |
* src/estream.c (flush_stream): Always call cookie's flush func.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
| |
* src/estream.c (_gpgrt_poll) [W32]: Use syscall clamp.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
| |
--
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/estream.c (_gpgrt_set_syscall_clamp)
(_gpgrt_get_syscall_clamp): Move to ...
* src/syscall-clamp.c: new file.
(_gpgrt_pre_syscall, _gpgrt_post_syscall): New.
* src/Makefile.am (libgpg_error_la_SOURCES): Add that file.
* src/estream.c: Replace the syscall wrapper with the new functions.
* src/posix-lock.c: Ditto.
* src/w32-lock.c: Ditto.
* src/posix-thread.c: Ditto.
* src/w32-thread.c: Ditto.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/estream.c (_gpgrt_poll): Do not return early if some streams are
found to be ready before even polling the others.
--
POSIX mandates that all streams are examined and returning early
violates that. It also imposes an order on how the callee serves the
streams, which might be incompatible with the order the callee wants
to serve them, leading to deadlocks.
Signed-off-by: Justus Winter <[email protected]>
|
|
|
|
|
|
|
| |
* src/estream.c (do_list_remove): Free the item.
(do_close): Free the buffer.
Signed-off-by: NIIBE Yutaka <[email protected]>
|
|
|
|
|
|
|
|
| |
* src/b64dec.c (_gpgrt_b64dec_proc): Add a comment.
* src/estream.c (_gpgrt_fread, _gpgrt_fwrite): Use &&.
* src/mkheader.c (xstrdup): Use memcpy as we know length.
Signed-off-by: NIIBE Yutaka <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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]>
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/estream.c (_gpgrt_poll) [W32]: Do not call the syscall clamp.
--
The system call clamp may only be used directloy around system calls.
We don't need them here because we use independent threads to
implement non-blocking behaviour. In fact the clamp may lead to a
deadlock.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
| |
* src/estream.c: Add trace calls to some functions.
* src/w32-estream.c: Replace existing trace calls by the new
framework.
--
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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]>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/estream.c (estream_cookie_w32): Add flag no_syscall_clamp.
(func_w32_create): Add arg no_syscall_clamp.
(func_w32_read): Do not call pre/post_syscall_clamp when flag is set.
(func_w32_write): Ditto.
(func_w32_seek): Ditto.
(do_w32open): Set NO_SYSCALL_CLAMP in pollable mode.
(es_create) [W32]: Make sure that pollable-mode is unly used with the
W32 backend.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
| |
* src/estream.c (es_flush, es_write_nbf): Fix setting of ERRNO to
EOPNOTSUPP.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
| |
--
A trailing comma in an enum is not groked by all compilers.
Binary operation should have their own parentheses to make it clear
that a binary operator was meant.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/Makefile.am (arch_sources): Add new file.
* src/estream.c (O_NONBLOCK): Move to 'gpgrt-int.h'.
(BUFFER_BLOCK_SIZE): Likewise.
(BUFFER_UNREAD_SIZE): Likewise.
(struct notify_list_s, notify_list_t): Likewise.
(struct _gpgrt_stream_internal, estream_internal_t): Likewise.
(X_POLLABLE): New macro.
(parse_mode): Parse keyword 'pollable', emulate O_NONBLOCK using the
same mechanism on Windows.
(_gpgrt_poll): Use the new '_gpgrt_w32_poll' on Windows.
* src/gpgrt-int.h (_gpgrt_functions_w32_pollable): New declaration.
(_gpgrt_w32_pollable_create): New prototype.
(_gpgrt_w32_poll): Likewise.
* src/w32-estream.c: New file. This code is adapted from GPGME.
* tests/t-poll.c (create_pipe): Create pollable streams.
GnuPG-bug-id: 2731
Signed-off-by: Justus Winter <[email protected]>
|
|
|
|
|
|
|
|
|
| |
* src/estream.c (struct _gpgrt_stream_internal): Add 'kind'.
(init_stream_obj): New parameter 'kind', initialize field.
(es_create): New parameter 'kind'. Update all callers.
* src/gpgrt-int.h (gpgrt_stream_backend_kind_t): New type.
Signed-off-by: Justus Winter <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/estream.c (cookie_ioctl_function_t): Move to 'gpgrt-int.h',
along with the macros for the IOCTL numbers.
(estream_functions_mem): Use the new type and add the ioctl function.
(estream_functions_fd): Likewise.
(estream_functions_w32): Likewise.
(estream_functions_fp): Likewise.
(init_stream_object): Use the new type, and also initialize
'func_ioctl'.
(es_create): Use the new type.
(_gpgrt_fopen): Adapt.
(_gpgrt_mopen): Likewise.
(_gpgrt_fopenmem): Likewise.
(_gpgrt_fopencookie): Likewise.
(_gpgrt_fdopen): Likewise.
(_gpgrt_fpopen): Likewise.
(do_w32open): Likewise.
* src/gpgrt-int.h (struct cookie_io_functions_s): New type.
Signed-off-by: Justus Winter <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/estream.c (X_SAMETHREAD, X_SYSOPEN): New macros.
(parse_mode): Rework how information flows from here to 'es_create'.
Instead of using an integer flag per mode, use flags.
(init_stream_obj): Adapt accordingly.
(es_create): Likewise.
(_gpgrt_fopen): Likewise.
(_gpgrt_mopen): Likewise.
(_gpgrt_fopenmem): Likewise.
(_gpgrt_fopencookie): Likewise.
(_gpgrt_fdopen): Likewise.
(_gpgrt_fpopen): Likewise.
(do_w32open): Likewise.
(_gpgrt_freopen): Likewise.
Signed-off-by: Justus Winter <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/visibility.c (gpgrt_get_syscall_clamp): New.
* src/gpg-error.vers, src/gpg-error.def.in: Add function.
* src/gpg-error.h.in: Ditto.
* src/estream.c (_gpgrt_get_syscall_clamp): New.
--
This function can be used by other libraries to set their own system
clamp functions.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/posix-lock.c (pre_lock_func, post_lock_func): New.
(_gpgrt_lock_set_lock_clamp): New.
(_gpgrt_lock_lock): Use clamp functions.
* src/w32-lock.c (pre_lock_func, post_lock_func): New.
(_gpgrt_lock_set_lock_clamp): New.
(_gpgrt_lock_lock): Use clamp functions.
* src/posix-lock.c (pre_syscall_func, post_syscall_func): New.
(_gpgrt_thread_set_syscall_clamp): New.
(_gpgrt_yield): Use clamp functions.
* src/w32-lock.c (pre_syscall_func, post_syscall_func): New.
(_gpgrt_thread_set_syscall_clamp): New.
(_gpgrt_yield): Use clamp functions.
* src/estream.c: Include lock.h and thread.h.
(do_deinit): Call _gpgrt_lock_set_lock_clamp.
(_gpgrt_set_syscall_clamp): Ditto.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
| |
* src/estream.c (parse_mode): Fix parsing the 'sysopen' flag.
Signed-off-by: Justus Winter <[email protected]>
|
|
|
|
|
|
|
| |
* src/estream.c (EWOULDBLOCK): Define fallback.
--
Older mingw versions (2.0) do not define EWOULDBLOCK in errno.h
|
|
|
|
|
|
| |
* src/estream.c (func_mem_ioctl): Set LEN from DATA_LEN.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
| |
* src/estream.c (S_IRGRP) [W32]: Protect against redefinition.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
| |
* src/estream.c (func_file_create): Remove dead assignment.
(doreadline): Do not decrement SPACE_LEFT before breaking the loop.
Add an extra block to limit the scope of that variable.
--
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/estream.c (es_writen): Set writing flag even if no data was
written.
--
GnuPG-bug-id: 2371
Signed-off-by: Werner Koch <[email protected]>
gniibe tracked the problem down to a fully valid change in GnuPG
(gnupg commit 12af2630cf4d1a39179179925fac8f2cce7504ff). He wrote:
This is the first instance for estream to do READ and WRITE
(in the history of the code > 10 years :-). In the [gnupg] function
agent_write_private_key, the pattern is:
es_fopen
es_fread
es_fseek
es_fwrite
which should work well, but if results core dump by assertion failure
in the function es_flush of libgpg-error.
|
|
|
|
|
|
|
|
|
|
| |
* src/estream.c (func_mem_create): Round up memory limit.
--
This is required so that giving a memory limit to es_fopenmem won't
fail if it is below the block size.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
| |
* src/estream.c (_gpgrt_poll) [W32]: Do not use FD_ISSET.
--
gpgrt_poll return an error on Windows anyway and thus it does not make
sense to use a possible undefined macro here.
Reported-by: Andre Heinecke
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
| |
* src/estream.c (parse_mode): Add arg "sysopen". Adjust all callers.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
| |
* src/estream.c: Replace all es_func_* to just func_*.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
| |
--
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
| |
* src/estream.c (SET_UNLESS_NONZERO): Remove macro.
(es_deinitialize): Replace that macro by direct code.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
--
* 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
|
|
|
|
|
| |
--
Signed-off-by: Justus Winter <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/estream.c (es_func_fd_write): Take care of a flush requests.
(es_func_w32_write): Ditto.
(es_func_fp_write): Ditto.
--
The write handlers may be called with (BUFFER,SIZE) of (NULL,0) to
propagate flush events to user supplied functions (es_fopencookie).
However we need to take care to also do this with the internal
handler. Might be a reason for system faults due to write or fwrite
with a NULL buffer; on Linux this seems to be harmless.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
| |
* src/estream.c (_gpgrt_stream_internal): Add indicators.hup.
(init_stream_obj): Init it.
(es_fill, es_flush, es_seek): Set that.
(_gpgrt_poll): Set event.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* configure.ac (AC_CHECK_HEADERS): Add sys/select.h and sys/time.h.
* src/estream.c: Include both header if available.
(COOKIE_IOCTL_NONBLOCK): New.
(struct estream_cookie_fd): Add field nonblock.
(func_fd_create): Set nonblock from MODEFLAGS.
(es_func_fd_ioctl): New.
(parse_mode): Add modeflag "nonblock".
(es_fill): Map EWOULDBLOCK to EAGAIN. Do not set error indicator for
EAGAIN.
(es_flush, es_seek, es_write_nbf): Map EWOULDBLOCK to EAGAIN.
(do_fdopen): Call COOKIE_IOCTL_NONBLOCK.
(_gpgrt_set_nonblock): New.
(_gpgrt_get_nonblock): New.
(_gpgrt_poll): New.
* src/gpg-error.h.in (struct _gpgrt_poll_s): New.
(gpgrt_poll_t, es_poll_t): New.
(es_set_nonblock, es_get_nonblock, es_poll): New.
* src/gpg-error.vers, src/gpg-error.def.in: Add gpgrt_set_nonblock,
gpgrt_get_nonblock, and gpgrt_poll.
* src/visibility.c (gpgrt_set_nonblock, gpgrt_get_nonblock): New.
(gpgrt_poll): New.
* tests/t-common.h (DIM): New.
* tests/t-poll.c: New.
* tests/Makefile.am (TESTS): Add t-poll.
(t_poll_LDADD): New.
--
The poll interface uses select(2) internally because that is more
portable than poll(2).
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
| |
* src/estream.c (es_set_indicators, es_get_indicator): Remove and
change callers to set/get indicators directly.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
| |
* src/estream.c (HAVE_DOSISH_SYSTEM): Define if needed.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
| |
* src/estream.c (fname_set_internal): Remove useless condition.
* src/mkheader.c (main): Ditto.
--
Detected by Stack 0.3.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/gpg-error.h.in (gpgrt_pending): Change to a macro.
(gpgrt_pending_unlocked): Change to a macro.
(_gpgrt_pending, _gpgrt_pending_unlocked): New private functions.
* src/visibility.c, src/visibility.h: Change accordingly.
* src/gpg-error.vers, src/gpg-error.def.in: Ditto.
* src/estream.c (_gpgrt_pending_unlocked): Rename to
_gpgrt__pending_unlocked.
(_gpgrt_pending): Rename to _gpgrt__pending.
--
The function are supposed to be used with gprt_getc and thus we need
to avoid the function call overhead. We may want to change them to
inline functions, though.
gpgrt_pending is changed to a macro with the idea that we eventually
can export the samestream flags and thus avoid the function call
overhead in the samethread case too.
|
|
|
|
| |
* src/estream.c (es_func_w32_read): Fix var name.
|
|
|
|
|
|
|
|
|
| |
* src/visibility.c (gpgrt_pending, gpgrt_pending_unlocked): New.
* src/estream.c (_gpgrt_pending, _gpgrt_pending_unlocked): New.
(check_pending): new.
(check_pending_fbf, check_pending_nbf): New.
(es_func_mem_read, es_func_fd_read, es_func_w32_read)
(es_func_fp_read, es_fill): Take care of the special 0 value for SIZE.
|
|
|
|
| |
--
|