diff options
| author | Daniel Kahn Gillmor <dkg@fifthhorseman.net> | 2017-12-08 01:23:58 -0500 |
|---|---|---|
| committer | David Bremner <david@tethera.net> | 2017-12-08 08:08:46 -0400 |
| commit | d137170b23f8ccd9f967445e101d6f694df1cad4 (patch) | |
| tree | a9d783de0ce8bcfcd59f49703e82adb5c8c240ff /util | |
| parent | 181d4091c408b8ca014ec245ecdae602942b70ce (diff) | |
crypto: record whether an actual decryption attempt happened
In our consolidation of _notmuch_crypto_decrypt, the callers lost
track a little bit of whether any actual decryption was attempted.
Now that we have the more-subtle "auto" policy, it's possible that
_notmuch_crypto_decrypt could be called without having any actual
decryption take place.
This change lets the callers be a little bit smarter about whether or
not any decryption was actually attempted.
Diffstat (limited to 'util')
| -rw-r--r-- | util/crypto.c | 7 | ||||
| -rw-r--r-- | util/crypto.h | 3 |
2 files changed, 8 insertions, 2 deletions
diff --git a/util/crypto.c b/util/crypto.c index bb587571..338f1d5d 100644 --- a/util/crypto.c +++ b/util/crypto.c @@ -140,7 +140,8 @@ void _notmuch_crypto_cleanup (unused(_notmuch_crypto_t *crypto)) #endif GMimeObject * -_notmuch_crypto_decrypt (notmuch_decryption_policy_t decrypt, +_notmuch_crypto_decrypt (bool *attempted, + notmuch_decryption_policy_t decrypt, notmuch_message_t *message, g_mime_3_unused(GMimeCryptoContext* crypto_ctx), GMimeMultipartEncrypted *part, @@ -162,6 +163,8 @@ _notmuch_crypto_decrypt (notmuch_decryption_policy_t decrypt, g_error_free (*err); *err = NULL; } + if (attempted) + *attempted = true; #if (GMIME_MAJOR_VERSION < 3) ret = g_mime_multipart_encrypted_decrypt_session (part, crypto_ctx, @@ -191,6 +194,8 @@ _notmuch_crypto_decrypt (notmuch_decryption_policy_t decrypt, if (decrypt == NOTMUCH_DECRYPT_AUTO) return ret; + if (attempted) + *attempted = true; #if (GMIME_MAJOR_VERSION < 3) ret = g_mime_multipart_encrypted_decrypt(part, crypto_ctx, decrypt_result, err); diff --git a/util/crypto.h b/util/crypto.h index dc95b4ca..c384601c 100644 --- a/util/crypto.h +++ b/util/crypto.h @@ -16,7 +16,8 @@ typedef struct _notmuch_crypto { } _notmuch_crypto_t; GMimeObject * -_notmuch_crypto_decrypt (notmuch_decryption_policy_t decrypt, +_notmuch_crypto_decrypt (bool *attempted, + notmuch_decryption_policy_t decrypt, notmuch_message_t *message, GMimeCryptoContext* crypto_ctx, GMimeMultipartEncrypted *part, |
