aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/compose.go
diff options
context:
space:
mode:
authorwitcher <witcher@wiredspace.de>2023-03-02 20:44:21 +0100
committerRobin Jarry <robin@jarry.cc>2023-03-02 22:09:11 +0100
commit58ca92bcd872e3114c9261819aae6118ea267d63 (patch)
tree7b31beab6b95420762f6ed18eb17178ebedd4564 /widgets/compose.go
parent8e70c7d40c62ae32463d1ff766b40a5e371bf2aa (diff)
downloadaerc-58ca92bcd872e3114c9261819aae6118ea267d63.tar.gz
pgp: fix segfault for opportunistic encryption
Commit 2af81a743048 ("pgp: add configurable error level for opportunistic encryption") introduced a bug where if the pgp-opportunistic-encrypt attribute is set to true and a new message is composed, aerc would crash. This is because no recipients have been specified, so checkEncryption() would fail early and *not* call updateCrypto(), which would then cause a segfault in SetEncrypt() later on. To avoid this, when the function would have returned early, it instead does *not* set c.encrypt to true and still calls updateCrypto(). Fixes: 2af81a743048 ("pgp: add configurable error level for opportunistic encryption") Signed-off-by: witcher <witcher@wiredspace.de> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'widgets/compose.go')
-rw-r--r--widgets/compose.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/widgets/compose.go b/widgets/compose.go
index dc4719a6..74493ac9 100644
--- a/widgets/compose.go
+++ b/widgets/compose.go
@@ -1511,6 +1511,8 @@ func (c *Composer) checkEncryptionKeys(_ string) bool {
mk = append(mk, rcpt)
}
}
+
+ encrypt := true
switch {
case len(mk) > 0:
c.SetEncrypt(false)
@@ -1527,13 +1529,14 @@ func (c *Composer) checkEncryptionKeys(_ string) bool {
}
}
c.aerc.statusline.PushError(st)
- return false
+ encrypt = false
case len(rcpts) == 0:
- return false
+ encrypt = false
}
+
// If callbacks were registered, encrypt will be set when user removes
// recipients with missing keys
- c.encrypt = true
+ c.encrypt = encrypt
err = c.updateCrypto()
if err != nil {
log.Warnf("failed update crypto: %v", err)