encrypt message should fail when encryption/siging fails. ENGINE-757
authorKrista 'DarthMama' Bennett <krista@pep.foundation>
Mon, 15 Jun 2020 20:49:07 +0200
branchENGINE-757
changeset 4742fc606be2e563
parent 4741 cddfaf522e7a
child 4743 a0f7ad59421b
encrypt message should fail when encryption/siging fails.
src/message_api.c
test/src/PassphraseTest.cc
     1.1 --- a/src/message_api.c	Mon Jun 15 20:29:37 2020 +0200
     1.2 +++ b/src/message_api.c	Mon Jun 15 20:49:07 2020 +0200
     1.3 @@ -1119,7 +1119,7 @@
     1.4          status = encrypt_and_sign(session, keys, mimetext, strlen(mimetext),
     1.5              &ctext, &csize);
     1.6      free(mimetext);
     1.7 -    if (ctext == NULL)
     1.8 +    if (ctext == NULL || status)
     1.9          goto pEp_error;
    1.10  
    1.11      dst->longmsg = strdup("this message was encrypted with p≡p "
    1.12 @@ -2231,6 +2231,10 @@
    1.13          status = PEP_UNKNOWN_ERROR;
    1.14          goto pEp_free;
    1.15      }
    1.16 +    else if (status) {
    1.17 +        free(encrypted_key_text);
    1.18 +        goto pEp_free; // FIXME - we need an error return overall
    1.19 +    }
    1.20  
    1.21      // We will have to delete this before returning, as we allocated it.
    1.22      bloblist_t* created_bl = NULL;
     2.1 --- a/test/src/PassphraseTest.cc	Mon Jun 15 20:29:37 2020 +0200
     2.2 +++ b/test/src/PassphraseTest.cc	Mon Jun 15 20:49:07 2020 +0200
     2.3 @@ -222,8 +222,8 @@
     2.4      
     2.5      message* enc_msg = NULL;
     2.6      status = encrypt_message(session, msg, NULL, &enc_msg, PEP_enc_PGP_MIME, 0);
     2.7 -    ASSERT_EQ(status, PEP_STATUS_OK);
     2.8 -    ASSERT_NE(enc_msg, nullptr);
     2.9 +    ASSERT_NE(status, PEP_STATUS_OK);
    2.10 +    ASSERT_EQ(enc_msg, nullptr);
    2.11      
    2.12      free_message(msg);
    2.13      free_message(enc_msg);