store signature fpr in sync state sync
authorVolker Birk <vb@pep-project.org>
Thu, 21 Mar 2019 12:54:20 +0100
branchsync
changeset 33639095efc623dd
parent 3362 a90c5e2081c3
child 3364 e3fb1b26d179
store signature fpr in sync state
src/message_api.c
sync/gen_message_func.ysl2
sync/gen_statemachine.ysl2
     1.1 --- a/src/message_api.c	Thu Mar 21 12:12:09 2019 +0100
     1.2 +++ b/src/message_api.c	Thu Mar 21 12:54:20 2019 +0100
     1.3 @@ -3856,21 +3856,8 @@
     1.4          const char *data;
     1.5          char *sync_fpr = NULL;
     1.6          PEP_STATUS tmpstatus = base_extract_message(session, msg, &size, &data, &sync_fpr);
     1.7 -        if (!tmpstatus && size && data) {
     1.8 -            pEp_identity *_from = identity_dup(msg->from);
     1.9 -            if (!_from) {
    1.10 -                free_message(*dst);
    1.11 -                *dst = NULL;
    1.12 -                free_stringlist(*keylist);
    1.13 -                *keylist = NULL;
    1.14 -                free(sync_fpr);
    1.15 -                return PEP_OUT_OF_MEMORY;
    1.16 -            }
    1.17 -            if (session->sync_state.common.from)
    1.18 -                free_identity(session->sync_state.common.from);
    1.19 -            session->sync_state.common.from = _from;
    1.20 -            signal_Sync_message(session, *rating, data, size, sync_fpr);
    1.21 -        }
    1.22 +        if (!tmpstatus && size && data)
    1.23 +            signal_Sync_message(session, *rating, data, size, msg->from, sync_fpr);
    1.24          free(sync_fpr);
    1.25      }
    1.26  
     2.1 --- a/sync/gen_message_func.ysl2	Thu Mar 21 12:12:09 2019 +0100
     2.2 +++ b/sync/gen_message_func.ysl2	Thu Mar 21 12:54:20 2019 +0100
     2.3 @@ -41,6 +41,7 @@
     2.4  struct «@name»_state_s {
     2.5      struct common_state_s {
     2.6          pEp_identity *from;
     2.7 +        char *signature_fpr;
     2.8      } common;
     2.9  
    2.10      `` apply "fsm", mode=state
     3.1 --- a/sync/gen_statemachine.ysl2	Thu Mar 21 12:12:09 2019 +0100
     3.2 +++ b/sync/gen_statemachine.ysl2	Thu Mar 21 12:54:20 2019 +0100
     3.3 @@ -198,7 +198,8 @@
     3.4                      PEP_rating rating,
     3.5                      const char *data,
     3.6                      size_t size,
     3.7 -                    const char *fpr
     3.8 +                    const pEp_identity *from,
     3.9 +                    const char *signature_fpr
    3.10                  );
    3.11  
    3.12              #ifdef __cplusplus
    3.13 @@ -311,7 +312,8 @@
    3.14                      PEP_rating rating,
    3.15                      const char *data,
    3.16                      size_t size,
    3.17 -                    const char *fpr
    3.18 +                    const pEp_identity *from,
    3.19 +                    const char *signature_fpr
    3.20                  )
    3.21              {
    3.22                  assert(session && data && size);
    3.23 @@ -324,12 +326,19 @@
    3.24                  PEP_STATUS status = PEP_STATUS_OK;
    3.25                  «@name»_event_t *ev = NULL;
    3.26  
    3.27 -                if (fpr) {
    3.28 -                    if (session->«yml:lcase(@name)»_state.common.from->fpr)
    3.29 -                        free(session->«yml:lcase(@name)»_state.common.from->fpr);
    3.30 -                    session->«yml:lcase(@name)»_state.common.from->fpr = strdup(fpr);
    3.31 -                    assert(session->«yml:lcase(@name)»_state.common.from->fpr);
    3.32 -                    if (!session->«yml:lcase(@name)»_state.common.from->fpr) {
    3.33 +                if (from) {
    3.34 +                    free_identity(session->«yml:lcase(@name)»_state.common.from);
    3.35 +                    session->«yml:lcase(@name)»_state.common.from = identity_dup(from);
    3.36 +                    if (!session->«yml:lcase(@name)»_state.common.from) {
    3.37 +                        status = PEP_OUT_OF_MEMORY;
    3.38 +                        goto the_end;
    3.39 +                    }
    3.40 +                }
    3.41 +
    3.42 +                if (signature_fpr) {
    3.43 +                    free(session->«yml:lcase(@name)»_state.common.signature_fpr);
    3.44 +                    session->«yml:lcase(@name)»_state.common.signature_fpr = strdup(signature_fpr);
    3.45 +                    if (!session->«yml:lcase(@name)»_state.common.signature_fpr) {
    3.46                          status = PEP_OUT_OF_MEMORY;
    3.47                          goto the_end;
    3.48                      }
    3.49 @@ -631,7 +640,7 @@
    3.50              for "message[@security='unencrypted']" {
    3.51              ||
    3.52                      case «../@name»__payload_PR_«yml:mixedCase(@name)»:
    3.53 -                        if (!fpr) {
    3.54 +                        if (!signature_fpr) {
    3.55                              status = PEP_«yml:ucase(ancestor::protocol/@name)»_ILLEGAL_MESSAGE;
    3.56                              goto the_end;
    3.57                          }