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>
This commit is contained in:
parent
e2be2dd4c0
commit
80f90c0d41
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue