2af81a7430481b3aec40f6a794db8cde4e1e18e4 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
*doesn't* set `c.encrypt` to `true` and still calls `updateCrypto()`.
Signed-off-by: witcher <witcher@wiredspace.de>
---
widgets/compose.go | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/widgets/compose.go b/widgets/compose.go
index dc4719a..74493ac 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)
--
2.39.2
witcher, Mar 02, 2023 at 20:44:
> 2af81a7430481b3aec40f6a794db8cde4e1e18e4 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
> *doesn't* set `c.encrypt` to `true` and still calls `updateCrypto()`.
>
> Signed-off-by: witcher <witcher@wiredspace.de>
Acked-by: Robin-Jarry <robin@jarry.cc>
Applied. Thanks!