[ostree] gpg: Use gpg_strerror_r for threadsafety
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree] gpg: Use gpg_strerror_r for threadsafety
- Date: Mon, 22 Feb 2016 23:07:45 +0000 (UTC)
commit f461c02bb55bf2853a3b81ed5c8618040ab54e98
Author: Colin Walters <walters verbum org>
Date: Mon Feb 22 16:50:28 2016 -0500
gpg: Use gpg_strerror_r for threadsafety
These APIs are rather painful...this is why GError exists.
src/libotutil/ot-gpg-utils.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/src/libotutil/ot-gpg-utils.c b/src/libotutil/ot-gpg-utils.c
index aa5b481..9414088 100644
--- a/src/libotutil/ot-gpg-utils.c
+++ b/src/libotutil/ot-gpg-utils.c
@@ -31,6 +31,7 @@ ot_gpgme_error_to_gio_error (gpgme_error_t gpg_error,
GError **error)
{
GIOErrorEnum errcode;
+ char errbuf[1024];
/* XXX This list is incomplete. Add cases as needed. */
@@ -42,9 +43,11 @@ ot_gpgme_error_to_gio_error (gpgme_error_t gpg_error,
/* special case - abort on out-of-memory */
case GPG_ERR_ENOMEM:
+ (void) gpg_strerror_r (gpg_error, errbuf, sizeof (errbuf));
+ errbuf[sizeof(errbuf)-1] = '\0';
g_error ("%s: %s",
gpgme_strsource (gpg_error),
- gpgme_strerror (gpg_error));
+ errbuf);
case GPG_ERR_INV_VALUE:
errcode = G_IO_ERROR_INVALID_ARGUMENT;
@@ -55,9 +58,11 @@ ot_gpgme_error_to_gio_error (gpgme_error_t gpg_error,
break;
}
+ (void) gpg_strerror_r (gpg_error, errbuf, sizeof (errbuf));
+ errbuf[sizeof(errbuf)-1] = '\0';
g_set_error (error, G_IO_ERROR, errcode, "%s: %s",
gpgme_strsource (gpg_error),
- gpgme_strerror (gpg_error));
+ errbuf);
}
gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]