mirror of
https://github.com/ostreedev/ostree.git
synced 2025-01-25 10:04:14 +03:00
gpg: Use gpg_strerror_r for threadsafety
These APIs are rather painful...this is why GError exists.
This commit is contained in:
parent
9f9d713a56
commit
f461c02bb5
@ -31,6 +31,7 @@ ot_gpgme_error_to_gio_error (gpgme_error_t gpg_error,
|
|||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
GIOErrorEnum errcode;
|
GIOErrorEnum errcode;
|
||||||
|
char errbuf[1024];
|
||||||
|
|
||||||
/* XXX This list is incomplete. Add cases as needed. */
|
/* 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 */
|
/* special case - abort on out-of-memory */
|
||||||
case GPG_ERR_ENOMEM:
|
case GPG_ERR_ENOMEM:
|
||||||
|
(void) gpg_strerror_r (gpg_error, errbuf, sizeof (errbuf));
|
||||||
|
errbuf[sizeof(errbuf)-1] = '\0';
|
||||||
g_error ("%s: %s",
|
g_error ("%s: %s",
|
||||||
gpgme_strsource (gpg_error),
|
gpgme_strsource (gpg_error),
|
||||||
gpgme_strerror (gpg_error));
|
errbuf);
|
||||||
|
|
||||||
case GPG_ERR_INV_VALUE:
|
case GPG_ERR_INV_VALUE:
|
||||||
errcode = G_IO_ERROR_INVALID_ARGUMENT;
|
errcode = G_IO_ERROR_INVALID_ARGUMENT;
|
||||||
@ -55,9 +58,11 @@ ot_gpgme_error_to_gio_error (gpgme_error_t gpg_error,
|
|||||||
break;
|
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",
|
g_set_error (error, G_IO_ERROR, errcode, "%s: %s",
|
||||||
gpgme_strsource (gpg_error),
|
gpgme_strsource (gpg_error),
|
||||||
gpgme_strerror (gpg_error));
|
errbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
Loading…
x
Reference in New Issue
Block a user