diff options
author | Moritz Poldrack <git@moritz.sh> | 2022-07-01 19:11:33 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-07-02 18:36:40 +0200 |
commit | 80f90c0d41858ddc80232965ce85c8e560a78fbd (patch) | |
tree | 74dbc2ac37dd8c7c0f07375e33ae7c2c0cf0dbe6 /lib/crypto/gpg/gpgbin | |
parent | e2be2dd4c0a9e2e5b00682a7e4236dfcd4a01fc4 (diff) | |
download | aerc-80f90c0d41858ddc80232965ce85c8e560a78fbd.tar.gz |
gpg: fix panic when signing an unparsable message
Fix the following error:
panic()
runtime/panic.go:838
bytes.(*Buffer).ReadFrom()
bytes/buffer.go:204
io.copyBuffer()
io/io.go:412
io.Copy()
io/io.go:385
git.sr.ht/~rjarry/aerc/lib/crypto/gpg/gpgbin.Sign()
git.sr.ht/~rjarry/aerc/lib/crypto/gpg/gpgbin/sign.go:25
git.sr.ht/~rjarry/aerc/lib/crypto/gpg.(*Signer).Close()
git.sr.ht/~rjarry/aerc/lib/crypto/gpg/writer.go:52
git.sr.ht/~rjarry/aerc/lib/crypto/gpg.multiCloser.Close()
git.sr.ht/~rjarry/aerc/lib/crypto/gpg/writer.go:92
git.sr.ht/~rjarry/aerc/widgets.(*Composer).WriteMessage()
git.sr.ht/~rjarry/aerc/widgets/compose.go:601
git.sr.ht/~rjarry/aerc/commands/compose.Send.Execute.func1()
git.sr.ht/~rjarry/aerc/commands/compose/send.go:127
Fixes: https://todo.sr.ht/~rjarry/aerc/53
Signed-off-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Tim Culverhouse <tim@timculverhouse.com>
Diffstat (limited to 'lib/crypto/gpg/gpgbin')
-rw-r--r-- | lib/crypto/gpg/gpgbin/sign.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/crypto/gpg/gpgbin/sign.go b/lib/crypto/gpg/gpgbin/sign.go index 35ab7e7f..31fd2b5a 100644 --- a/lib/crypto/gpg/gpgbin/sign.go +++ b/lib/crypto/gpg/gpgbin/sign.go @@ -2,6 +2,7 @@ package gpgbin import ( "bytes" + "fmt" "io" "git.sr.ht/~rjarry/aerc/models" @@ -20,7 +21,10 @@ func Sign(r io.Reader, from string) ([]byte, string, error) { outRdr := bytes.NewReader(g.stdout.Bytes()) var md models.MessageDetails - parse(outRdr, &md) + err := parse(outRdr, &md) + if err != nil { + return nil, "", fmt.Errorf("failed to parse messagedetails: %v", err) + } var buf bytes.Buffer io.Copy(&buf, md.Body) return buf.Bytes(), md.Micalg, nil |