~rjarry/aerc-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
2 2

[PATCH aerc] pgp: fix segfault for opportunistic encryption

Details
Message ID
<20230302194421.291084-1-witcher@wiredspace.de>
DKIM signature
pass
Download raw message
Patch: +6 -3
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

[aerc/patches] build success

builds.sr.ht <builds@sr.ht>
Details
Message ID
<CQW5OSHSYC1P.VNBLULNM7HPJ@cirno2>
In-Reply-To
<20230302194421.291084-1-witcher@wiredspace.de> (view parent)
DKIM signature
missing
Download raw message
aerc/patches: SUCCESS in 4m38s

[pgp: fix segfault for opportunistic encryption][0] from [witcher][1]

[0]: https://lists.sr.ht/~rjarry/aerc-devel/patches/39455
[1]: witcher@wiredspace.de

✓ #950699 SUCCESS aerc/patches/openbsd.yml     https://builds.sr.ht/~rjarry/job/950699
✓ #950698 SUCCESS aerc/patches/alpine-edge.yml https://builds.sr.ht/~rjarry/job/950698
Details
Message ID
<CQW7FHJBP503.KA06LOWB6YJO@ringo>
In-Reply-To
<20230302194421.291084-1-witcher@wiredspace.de> (view parent)
DKIM signature
pass
Download raw message
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!
Reply to thread Export thread (mbox)