Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 136ee8e3 authored by Vincent Breitmoser's avatar Vincent Breitmoser
Browse files

fix possible NPE in message crypto helper

parent 23bf474d
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -347,7 +347,7 @@ public class MessageCryptoHelper {
    }

    private void callAsyncDetachedVerify(Intent intent) throws IOException, MessagingException {
        OpenPgpDataSource dataSource = getDataSourceForSignedData();
        OpenPgpDataSource dataSource = getDataSourceForSignedData(currentCryptoPart.part);

        byte[] signatureData = MessageDecryptVerifier.getSignatureData(currentCryptoPart.part);
        intent.putExtra(OpenPgpApi.EXTRA_DETACHED_SIGNATURE, signatureData);
@@ -368,12 +368,12 @@ public class MessageCryptoHelper {
        });
    }

    private OpenPgpDataSource getDataSourceForSignedData() throws IOException {
    private OpenPgpDataSource getDataSourceForSignedData(final Part signedPart) throws IOException {
        return new OpenPgpDataSource() {
            @Override
            public void writeTo(OutputStream os) throws IOException {
                try {
                    Multipart multipartSignedMultipart = (Multipart) currentCryptoPart.part.getBody();
                    Multipart multipartSignedMultipart = (Multipart) signedPart.getBody();
                    BodyPart signatureBodyPart = multipartSignedMultipart.getBodyPart(0);
                    Log.d(K9.LOG_TAG, "signed data type: " + signatureBodyPart.getMimeType());
                    signatureBodyPart.writeTo(os);