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.
This commit is contained in:
Andre Heinecke 2019-03-27 17:47:41 +01:00
parent 19a4c4daa2
commit 4a4680f890
No known key found for this signature in database
GPG Key ID: 2978E9D40CBABA5C

View File

@ -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);