Home GnuPG

core: New functions gpgrt_fprintf_sf anf gpgrt_fprintf_sf_unlocked.

Description

core: New functions gpgrt_fprintf_sf anf gpgrt_fprintf_sf_unlocked.

* 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 <wk@gnupg.org>

Details

Provenance
wernerAuthored on Nov 26 2018, 8:22 PM
Parents
rEffb49b72f132: core: Add a limited version of gpgrt_ftruncate.
Branches
Unknown
Tags
Unknown