From 15050ce5fce4ed815503db7c029abb38d08970d6 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Thu, 2 Feb 2017 12:35:59 +0100 Subject: core: Replace all calls to *sprintf by gpgrt_*sprintf. * configure.ac (vasprintf): Remove check. * src/vasprintf.c: Remove file. * src/util.h (vasprintf, asprintf): Remove prototypes. Replace all calls to vasprintf and asprintf by gpgrt_vasprintf or gpgrt_asprintf. Also take care to use gpgrt_free on the returned value. * src/w32-util.c (_gpgme_get_gpgconf_path): Replace a gpgrt_asprintf by _gpgme_strconcat. (snprintf): New macro to use gpgrt_snprintf instead of the system's standard snprintf. Signed-off-by: Werner Koch --- src/engine-gpg.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/engine-gpg.c') diff --git a/src/engine-gpg.c b/src/engine-gpg.c index 75ba4bdb..21ca02a8 100644 --- a/src/engine-gpg.c +++ b/src/engine-gpg.c @@ -74,6 +74,10 @@ struct fd_data_map_s }; +/* NB.: R_LINE is allocated an gpgrt function and thus gpgrt_free + * shall be used to release it. This takes care of custom memory + * allocators and avoids problems on Windows with different runtimes + * used for libgpg-error/gpgrt and gpgme. */ typedef gpgme_error_t (*colon_preprocessor_t) (char *line, char **rline); struct engine_gpg @@ -1346,7 +1350,7 @@ read_colon_line (engine_gpg_t gpg) } while (linep && *linep); - free (line); + gpgrt_free (line); } else gpg->colon.fnc (gpg->colon.fnc_value, buffer); @@ -2513,7 +2517,7 @@ gpg_keylist_preprocess (char *line, char **r_line) n = strlen (field[1]); if (n > 16) { - if (asprintf (r_line, + if (gpgrt_asprintf (r_line, "pub:o%s:%s:%s:%s:%s:%s::::::::\n" "fpr:::::::::%s:", field[6], field[3], field[2], field[1] + n - 16, @@ -2522,7 +2526,7 @@ gpg_keylist_preprocess (char *line, char **r_line) } else { - if (asprintf (r_line, + if (gpgrt_asprintf (r_line, "pub:o%s:%s:%s:%s:%s:%s::::::::", field[6], field[3], field[2], field[1], field[4], field[5]) < 0) @@ -2580,7 +2584,7 @@ gpg_keylist_preprocess (char *line, char **r_line) } *dst = '\0'; - if (asprintf (r_line, "uid:o%s::::%s:%s:::%s:", + if (gpgrt_asprintf (r_line, "uid:o%s::::%s:%s:::%s:", field[4], field[2], field[3], uid) < 0) return gpg_error_from_syserror (); } -- cgit v1.2.3