sync bug: if inject_sync_message is present, we were overwriting the decrypt_message status. sync
authorKrista 'DarthMama' Bennett <krista@pep.foundation>
Tue, 26 Feb 2019 06:02:21 +0100
branchsync
changeset 3319b36b64dfcf0d
parent 3312 fb0e761dda0f
child 3321 528a262bd1f0
child 3322 e51a7e76dcd5
sync bug: if inject_sync_message is present, we were overwriting the decrypt_message status.
src/message_api.c
test/src/engine_tests/MessageApiTests.cc
     1.1 --- a/src/message_api.c	Sun Feb 24 14:08:53 2019 +0100
     1.2 +++ b/src/message_api.c	Tue Feb 26 06:02:21 2019 +0100
     1.3 @@ -1638,8 +1638,9 @@
     1.4      char* longmsg = NULL;
     1.5      char* shortmsg = NULL;
     1.6      char* msg_wrap_info = NULL;
     1.7 -    separate_short_and_long(src->longmsg, &shortmsg, &msg_wrap_info,
     1.8 -                            &longmsg);
     1.9 +    if (src->longmsg)
    1.10 +        separate_short_and_long(src->longmsg, &shortmsg, &msg_wrap_info,
    1.11 +                                &longmsg);
    1.12      if (longmsg) {                    
    1.13          free(src->longmsg);
    1.14          free(shortmsg);
    1.15 @@ -3852,8 +3853,8 @@
    1.16          size_t size;
    1.17          const char *data;
    1.18          char *sync_fpr = NULL;
    1.19 -        status = base_extract_message(session, msg, &size, &data, &sync_fpr);
    1.20 -        if (!status && size && data) {
    1.21 +        PEP_STATUS tmpstatus = base_extract_message(session, msg, &size, &data, &sync_fpr);
    1.22 +        if (!tmpstatus && size && data) {
    1.23              pEp_identity *_from = identity_dup(msg->from);
    1.24              if (!_from) {
    1.25                  free_message(*dst);
    1.26 @@ -4849,4 +4850,3 @@
    1.27      free_identity(ident);
    1.28      return status;
    1.29  }
    1.30 -
     2.1 --- a/test/src/engine_tests/MessageApiTests.cc	Sun Feb 24 14:08:53 2019 +0100
     2.2 +++ b/test/src/engine_tests/MessageApiTests.cc	Tue Feb 26 06:02:21 2019 +0100
     2.3 @@ -142,7 +142,7 @@
     2.4      PEP_decrypt_flags_t flags2;
     2.5      flags2 = 0;
     2.6      PEP_STATUS status6 = decrypt_message(session, msg5, &msg6, &keylist5, &rating2, &flags2);
     2.7 -    TEST_ASSERT_MSG((status6 == PEP_DECRYPT_NO_KEY), "status6 == PEP_DECRYPT_NO_KEY");
     2.8 +    TEST_ASSERT_MSG((status6 == PEP_DECRYPT_NO_KEY), tl_status_string(status6));
     2.9      TEST_ASSERT_MSG((msg6 == NULL), "msg6 == NULL");
    2.10      TEST_ASSERT_MSG((keylist5 == NULL), "keylist5 == NULL");
    2.11      TEST_ASSERT_MSG((rating2 == PEP_rating_have_no_key), "rating2 == PEP_rating_have_no_key");