aboutsummaryrefslogtreecommitdiff
path: root/util/crypto.c
diff options
context:
space:
mode:
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>2019-08-29 11:38:50 -0400
committerDavid Bremner <david@tethera.net>2019-09-01 08:38:11 -0300
commitab0ae8b1c086ca3878f16ce40cc421eeb206c79e (patch)
tree2ed00ac849133135c2d2ff262ba9a104cfad788c /util/crypto.c
parent8b25643d08b9388ae9c38837a3dfd3dbc6b085cf (diff)
util/crypto: _n_m_crypto_potential_payload returns whether part is the payload
Our _notmuch_message_crypto_potential_payload implementation could only return a failure if bad arguments were passed to it. It is an internal function, so if that happens it's an entirely internal bug for notmuch. It will be more useful for this function to return whether or not the part is in fact a cryptographic payload, so we dispense with the status return. If some future change suggests adding a status return back, there are only a handful of call sites, and no pressure to retain a stable API, so it could be changed easily. But for now, go with the simpler function. We will use this return value in future patches, to make different decisions based on whether a part is the cryptographic payload or not. But for now, we just leave the places where it gets invoked marked with (void) to show that the result is ignored. Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
Diffstat (limited to 'util/crypto.c')
-rw-r--r--util/crypto.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/util/crypto.c b/util/crypto.c
index 3845ade8..0bb6f526 100644
--- a/util/crypto.c
+++ b/util/crypto.c
@@ -20,6 +20,7 @@
#include "crypto.h"
#include <strings.h>
+#include "error_util.h"
#define unused(x) x __attribute__ ((unused))
#define ARRAY_SIZE(arr) (sizeof (arr) / sizeof (arr[0]))
@@ -135,19 +136,20 @@ _notmuch_message_crypto_potential_sig_list (_notmuch_message_crypto_t *msg_crypt
}
-notmuch_status_t
+bool
_notmuch_message_crypto_potential_payload (_notmuch_message_crypto_t *msg_crypto, GMimeObject *part, GMimeObject *parent, int childnum)
{
const char *protected_headers = NULL;
const char *forwarded = NULL;
const char *subject = NULL;
- if (! msg_crypto || ! part)
- return NOTMUCH_STATUS_NULL_POINTER;
+ if ((! msg_crypto) || (! part))
+ INTERNAL_ERROR ("_notmuch_message_crypto_potential_payload() got NULL for %s\n",
+ msg_crypto? "part" : "msg_crypto");
/* only fire on the first payload part encountered */
if (msg_crypto->payload_encountered)
- return NOTMUCH_STATUS_SUCCESS;
+ return false;
/* the first child of multipart/encrypted that matches the
* encryption protocol should be "control information" metadata,
@@ -159,7 +161,7 @@ _notmuch_message_crypto_potential_payload (_notmuch_message_crypto_t *msg_crypto
if (ct && enc_type) {
const char *part_type = g_mime_content_type_get_mime_type (ct);
if (part_type && strcmp (part_type, enc_type) == 0)
- return NOTMUCH_STATUS_SUCCESS;
+ return false;
}
}
@@ -169,7 +171,7 @@ _notmuch_message_crypto_potential_payload (_notmuch_message_crypto_t *msg_crypto
* envelope: */
if ((msg_crypto->decryption_status != NOTMUCH_MESSAGE_DECRYPTED_FULL) &&
(msg_crypto->sig_list == NULL))
- return NOTMUCH_STATUS_SUCCESS;
+ return false;
/* Verify that this payload has headers that are intended to be
* exported to the larger message: */
@@ -196,7 +198,7 @@ _notmuch_message_crypto_potential_payload (_notmuch_message_crypto_t *msg_crypto
msg_crypto->payload_subject = talloc_strdup (msg_crypto, subject);
}
- return NOTMUCH_STATUS_SUCCESS;
+ return true;
}