diff options
author | Andre Heinecke <[email protected]> | 2019-03-27 16:47:41 +0000 |
---|---|---|
committer | Andre Heinecke <[email protected]> | 2019-03-27 16:47:41 +0000 |
commit | 4a4680f8901ecdcb7e8d5ed55f48226ccfccd7c8 (patch) | |
tree | c4f7fb22247d24bb556eeeafacf3fc3e1c5f7e75 | |
parent | core: Fix assuan logger-fd hack for windows (diff) | |
download | gpgme-4a4680f8901ecdcb7e8d5ed55f48226ccfccd7c8.tar.gz gpgme-4a4680f8901ecdcb7e8d5ed55f48226ccfccd7c8.zip |
core, w32: Fix format string errors on windows
* src/debug.c (_gpgme_debug): Use gpgrt_vasprintf instead of
vfprintf to have a more portable format.
--
This fixes crashes on Windows because "%zu" is used which
is not natively supported on Windows but which gpgrt supports.
-rw-r--r-- | src/debug.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/debug.c b/src/debug.c index 81c2a90c..79e38ce1 100644 --- a/src/debug.c +++ b/src/debug.c @@ -255,6 +255,8 @@ _gpgme_debug (int level, int mode, const char *func, const char *tagname, va_list arg_ptr; int saved_errno; int need_lf; + char *output; + int out_len; if (debug_level < level) return 0; @@ -307,7 +309,12 @@ _gpgme_debug (int level, int mode, const char *func, const char *tagname, } need_lf = (mode != -1 && (!format || !*format)); - vfprintf (errfp, format, arg_ptr); + out_len = gpgrt_vasprintf (&output, format, arg_ptr); + if (out_len >= 0) + { + fwrite (output, out_len, 1, errfp); + free (output); + } va_end (arg_ptr); if (need_lf || (format && *format && format[strlen (format) - 1] != '\n')) putc ('\n', errfp); |