X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=mime-node.c;h=7363e2224026e0d206247e2777f6aee368d9957f;hp=e96e6639716aa017b1b36476900354d51563917b;hb=1fdc08d0ffab;hpb=33c8777a967ece2dd4bbda7e83a4e07c195abf51 diff --git a/mime-node.c b/mime-node.c index e96e6639..7363e222 100644 --- a/mime-node.c +++ b/mime-node.c @@ -14,7 +14,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Authors: Carl Worth * Keith Packard @@ -245,10 +245,12 @@ _mime_node_create (mime_node_t *parent, GMimeObject *part) GMimeContentType *content_type = g_mime_object_get_content_type (part); const char *protocol = g_mime_content_type_get_parameter (content_type, "protocol"); cryptoctx = notmuch_crypto_get_context (node->ctx->crypto, protocol); + if (!cryptoctx) + return NULL; } /* Handle PGP/MIME parts */ - if (GMIME_IS_MULTIPART_ENCRYPTED (part) && node->ctx->crypto->decrypt && cryptoctx) { + if (GMIME_IS_MULTIPART_ENCRYPTED (part) && node->ctx->crypto->decrypt) { if (node->nchildren != 2) { /* this violates RFC 3156 section 4, so we won't bother with it. */ fprintf (stderr, "Error: %d part(s) for a multipart/encrypted " @@ -257,7 +259,7 @@ _mime_node_create (mime_node_t *parent, GMimeObject *part) } else { node_decrypt_and_verify (node, part, cryptoctx); } - } else if (GMIME_IS_MULTIPART_SIGNED (part) && node->ctx->crypto->verify && cryptoctx) { + } else if (GMIME_IS_MULTIPART_SIGNED (part) && node->ctx->crypto->verify) { if (node->nchildren != 2) { /* this violates RFC 3156 section 5, so we won't bother with it. */ fprintf (stderr, "Error: %d part(s) for a multipart/signed message " @@ -322,20 +324,21 @@ mime_node_child (mime_node_t *parent, int child) static mime_node_t * _mime_node_seek_dfs_walk (mime_node_t *node, int *n) { - mime_node_t *ret = NULL; int i; if (*n == 0) return node; *n -= 1; - for (i = 0; i < node->nchildren && !ret; i++) { + for (i = 0; i < node->nchildren; i++) { mime_node_t *child = mime_node_child (node, i); - ret = _mime_node_seek_dfs_walk (child, n); - if (!ret) - talloc_free (child); + mime_node_t *ret = _mime_node_seek_dfs_walk (child, n); + if (ret) + return ret; + + talloc_free (child); } - return ret; + return NULL; } mime_node_t *