FIX of pgp_sequoia: size off by one sync
authorVolker Birk <vb@pep-project.org>
Tue, 28 May 2019 20:26:45 +0200
branchsync
changeset 37583c8a25f6f2c2
parent 3757 bf2916b900bf
child 3759 3a757e143664
FIX of pgp_sequoia: size off by one
src/message_api.c
src/pgp_sequoia.c
sync/gen_statemachine.ysl2
     1.1 --- a/src/message_api.c	Tue May 28 17:58:34 2019 +0200
     1.2 +++ b/src/message_api.c	Tue May 28 20:26:45 2019 +0200
     1.3 @@ -1572,7 +1572,7 @@
     1.4  PEP_STATUS _attach_key(PEP_SESSION session, const char* fpr, message *msg)
     1.5  {
     1.6      char *keydata = NULL;
     1.7 -    size_t size;
     1.8 +    size_t size = 0;
     1.9  
    1.10      PEP_STATUS status = export_key(session, fpr, &keydata, &size);
    1.11      assert(status == PEP_STATUS_OK);
    1.12 @@ -1580,7 +1580,7 @@
    1.13          return status;
    1.14      assert(size);
    1.15  
    1.16 -     bloblist_t *bl = bloblist_add(msg->attachments, keydata, size, "application/pgp-keys",
    1.17 +    bloblist_t *bl = bloblist_add(msg->attachments, keydata, size, "application/pgp-keys",
    1.18                        "file://pEpkey.asc");
    1.19  
    1.20      if (msg->attachments == NULL && bl)
    1.21 @@ -3898,8 +3898,8 @@
    1.22          if (!tmpstatus && size && data) {
    1.23              if (sync_fpr)
    1.24                  signal_Sync_message(session, *rating, data, size, msg->from, sync_fpr);
    1.25 -            else
    1.26 -                signal_Sync_message(session, *rating, data, size, msg->from, NULL);
    1.27 +            else if (*keylist)
    1.28 +                signal_Sync_message(session, *rating, data, size, msg->from, (*keylist)->value);
    1.29          }
    1.30          free(sync_fpr);
    1.31      }
     2.1 --- a/src/pgp_sequoia.c	Tue May 28 17:58:34 2019 +0200
     2.2 +++ b/src/pgp_sequoia.c	Tue May 28 20:26:45 2019 +0200
     2.3 @@ -2096,6 +2096,8 @@
     2.4      if (tpk)
     2.5          pgp_tpk_free(tpk);
     2.6  
     2.7 +    (*size)--;  // Sequoia is delivering the 0 byte at the end with size, but
     2.8 +                // pEp is expecting it without
     2.9      T("(%s) -> %s", fpr, pEp_status_to_string(status));
    2.10      return status;
    2.11  }
     3.1 --- a/sync/gen_statemachine.ysl2	Tue May 28 17:58:34 2019 +0200
     3.2 +++ b/sync/gen_statemachine.ysl2	Tue May 28 20:26:45 2019 +0200
     3.3 @@ -335,6 +335,12 @@
     3.4                  if (!(session && data && size))
     3.5                      return PEP_ILLEGAL_VALUE;
     3.6  
     3.7 +                if (from && from->fpr && signature_fpr) {
     3.8 +                    // ignore own messages
     3.9 +                    if (strcmp(from->fpr, signature_fpr) == 0)
    3.10 +                        return PEP_STATUS_OK;
    3.11 +                }
    3.12 +
    3.13                  if (!session->inject_«yml:lcase(@name)»_event)
    3.14                     return PEP_«yml:ucase(@name)»_NO_INJECT_CALLBACK;
    3.15