[balsa] autocrypt: fix crash when importing a half-broken key fails
- From: Albrecht Dreß <albrecht src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa] autocrypt: fix crash when importing a half-broken key fails
- Date: Wed, 9 Dec 2020 19:57:39 +0000 (UTC)
commit 8c32f9f9d6766b18ee62a61bf9376053d9b6ae73
Author: Albrecht Dreß <albrecht dress arcor de>
Date: Wed Dec 9 20:58:06 2020 +0100
autocrypt: fix crash when importing a half-broken key fails
Return FALSE from extract_ac_keydata() if an Autocrypt header is present
but contains a broken key, resulting in a failed import into GpgME. The
outcome of this is a crash in the caller due to an access to
uninitialised memory.
Signed-off-by: Albrecht Dreß <albrecht dress arcor de>
libbalsa/autocrypt.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
---
diff --git a/libbalsa/autocrypt.c b/libbalsa/autocrypt.c
index af081fa83..4dacc2cfb 100644
--- a/libbalsa/autocrypt.c
+++ b/libbalsa/autocrypt.c
@@ -670,7 +670,7 @@ extract_ac_keydata(GMimeAutocryptHeader *autocrypt_header, ac_key_data_t *dest,
gboolean success = FALSE;
keydata = g_mime_autocrypt_header_get_keydata(autocrypt_header);
- if (keydata) {
+ if (keydata != NULL) {
gpgme_ctx_t ctx;
dest->keydata = g_bytes_get_data(keydata, &dest->keysize);
@@ -696,11 +696,14 @@ extract_ac_keydata(GMimeAutocryptHeader *autocrypt_header, ac_key_data_t *dest,
if ((key != NULL) && (key->subkeys != NULL)) {
dest->fingerprint = g_strdup(key->subkeys->fpr);
dest->expires = key->subkeys->expires;
+ } else {
+ success = FALSE;
}
} else {
g_warning("Failed to import or list key data for '%s': %s (%u keys,
%u bad)",
g_mime_autocrypt_header_get_address_as_string(autocrypt_header),
(gpg_error != NULL) ? gpg_error->message : "unknown", (keys
!= NULL) ? g_list_length(keys) : 0U, bad_keys);
+ success = FALSE;
}
g_clear_error(&gpg_error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]