setting sync_state.common_from sync
authorVolker Birk <vb@pep.foundation>
Tue, 20 Nov 2018 17:37:00 +0100
branchsync
changeset 3144334a6c3faacd
parent 3143 81c80e27cbf7
child 3145 e8562bd82a1d
setting sync_state.common_from
src/baseprotocol.c
src/message_api.c
sync/gen_statemachine.ysl2
     1.1 --- a/src/baseprotocol.c	Tue Nov 20 17:18:46 2018 +0100
     1.2 +++ b/src/baseprotocol.c	Tue Nov 20 17:37:00 2018 +0100
     1.3 @@ -171,8 +171,6 @@
     1.4              status = PEP_OUT_OF_MEMORY;
     1.5              goto the_end;
     1.6          }
     1.7 -
     1.8 -        *fpr = _fpr;
     1.9      }
    1.10  
    1.11      *size = _payload_size;
     2.1 --- a/src/message_api.c	Tue Nov 20 17:18:46 2018 +0100
     2.2 +++ b/src/message_api.c	Tue Nov 20 17:37:00 2018 +0100
     2.3 @@ -3754,14 +3754,23 @@
     2.4  
     2.5      message *msg = *dst ? *dst : src;
     2.6  
     2.7 -    if (session->inject_sync_event && msg) {
     2.8 +    if (session->inject_sync_event && msg && msg->from) {
     2.9          size_t size;
    2.10          const char *data;
    2.11          char *sync_fpr = NULL;
    2.12          status = base_extract_message(session, msg, &size, &data, &sync_fpr);
    2.13 -        const char *fpr = (*keylist && (*keylist)->value) ? (*keylist)->value : sync_fpr;
    2.14 -        if (size && data && fpr)
    2.15 -            signal_Sync_message(session, *rating, data, size, fpr);
    2.16 +        if (!status && size && data) {
    2.17 +            pEp_identity *_from = identity_dup(msg->from);
    2.18 +            if (!_from) {
    2.19 +                free_message(*dst);
    2.20 +                *dst = NULL;
    2.21 +                free_stringlist(*keylist);
    2.22 +                *keylist = NULL;
    2.23 +                return PEP_OUT_OF_MEMORY;
    2.24 +            }
    2.25 +            memcpy(&session->sync_state.common.from, _from, sizeof(pEp_identity));
    2.26 +            signal_Sync_message(session, *rating, data, size, sync_fpr);
    2.27 +        }
    2.28          free(sync_fpr);
    2.29      }
    2.30  
     3.1 --- a/sync/gen_statemachine.ysl2	Tue Nov 20 17:18:46 2018 +0100
     3.2 +++ b/sync/gen_statemachine.ysl2	Tue Nov 20 17:37:00 2018 +0100
     3.3 @@ -339,13 +339,15 @@
     3.4                          goto the_end;
     3.5                  }
     3.6  
     3.7 -                if (session->«yml:lcase(@name)»_state.common.from->fpr)
     3.8 -                    free(session->«yml:lcase(@name)»_state.common.from->fpr);
     3.9 -                session->«yml:lcase(@name)»_state.common.from->fpr = strdup(fpr);
    3.10 -                assert(session->«yml:lcase(@name)»_state.common.from->fpr);
    3.11 -                if (!session->«yml:lcase(@name)»_state.common.from->fpr) {
    3.12 -                    status = PEP_OUT_OF_MEMORY;
    3.13 -                    goto the_end;
    3.14 +                if (fpr) {
    3.15 +                    if (session->«yml:lcase(@name)»_state.common.from->fpr)
    3.16 +                        free(session->«yml:lcase(@name)»_state.common.from->fpr);
    3.17 +                    session->«yml:lcase(@name)»_state.common.from->fpr = strdup(fpr);
    3.18 +                    assert(session->«yml:lcase(@name)»_state.common.from->fpr);
    3.19 +                    if (!session->«yml:lcase(@name)»_state.common.from->fpr) {
    3.20 +                        status = PEP_OUT_OF_MEMORY;
    3.21 +                        goto the_end;
    3.22 +                    }
    3.23                  }
    3.24  
    3.25                  ev = new_«@name»_event(fsm, event, msg);