]> git.notmuchmail.org Git - notmuch/commit
cli/crypto: fix segfault on failed gmime2 crypto context creation
authorJani Nikula <jani@nikula.org>
Mon, 16 Oct 2017 15:40:44 +0000 (18:40 +0300)
committerDavid Bremner <david@tethera.net>
Sun, 5 Nov 2017 19:41:13 +0000 (15:41 -0400)
commitcd3f5e1a934b9952ca718e0c5bc1471b3884020c
tree88b27329063cf3cc8dfe872b4263bdd061faf039
parent949c27144e0b9294267511993a109c29d319a23d
cli/crypto: fix segfault on failed gmime2 crypto context creation

Commit 1fdc08d0ffab ("cli/crypto: treat failure to create a crypto
context as fatal.") started treating crypto context creation failures
"as fatal", returning NULL from _mime_node_create().

Unfortunately, we do not have NULL checks for _mime_node_create()
failures. The only caller, mime_node_child(), could check and return
NULL (as it's documented to do on errors) but none of the several call
sites have NULL checks either. And none of them really have a trivial
but feasible and graceful way of recovery.

So while the right thing to do would be to handle NULL returns
properly all over the place, and we have other scenarios that do
return NULL from above mentioned functions, the crypto context
creation failure is something that does seem to show up regularly in
some scenarios, revert back to the functionality before commit
1fdc08d0ffab as an interim fix.
mime-node.c