KeySync: change UUID after entering group to avoid processing all pending handshake request leftover from beaconing all the group
authorEdouard Tisserant <edouard@pep-project.org>
Mon, 13 Feb 2017 00:07:28 +0100
changeset 1575ae0c4b0953a5
parent 1574 12b7a45140d3
child 1578 a676a68136e3
child 1580 b2b599902703
child 1585 655cfb838ac6
KeySync: change UUID after entering group to avoid processing all pending handshake request leftover from beaconing all the group
src/sync_actions.c
src/sync_impl.c
     1.1 --- a/src/sync_actions.c	Sun Feb 12 22:45:02 2017 +0100
     1.2 +++ b/src/sync_actions.c	Mon Feb 13 00:07:28 2017 +0100
     1.3 @@ -292,6 +292,13 @@
     1.4  
     1.5      // groups have no uuid for now
     1.6      status = set_device_group(session, "1");
     1.7 +
     1.8 +    // change sync_uuid when entering group 
     1.9 +    // thus ignoring unprocessed handshakes
    1.10 +    // addressed to previous self (sole) once in.
    1.11 +    pEpUUID uuid;
    1.12 +    uuid_generate_random(uuid);
    1.13 +    uuid_unparse_upper(uuid, session->sync_uuid);
    1.14      
    1.15      return status;
    1.16  }
     2.1 --- a/src/sync_impl.c	Sun Feb 12 22:45:02 2017 +0100
     2.2 +++ b/src/sync_impl.c	Mon Feb 13 00:07:28 2017 +0100
     2.3 @@ -63,6 +63,13 @@
     2.4                  break;
     2.5  
     2.6              case DeviceGroup_Protocol__payload_PR_handshakeRequest:
     2.7 +                // re-check uuid in case sync_uuid changed while in the queue
     2.8 +                if (strncmp(session->sync_uuid,
     2.9 +                            (const char *)msg->payload.choice.handshakeRequest.partner.user_id->buf,
    2.10 +                            msg->payload.choice.handshakeRequest.partner.user_id->size) != 0){
    2.11 +                    status = PEP_SYNC_ILLEGAL_MESSAGE;
    2.12 +                    goto error;
    2.13 +                }
    2.14                  event = HandshakeRequest;
    2.15                  break;
    2.16  
    2.17 @@ -71,6 +78,14 @@
    2.18                  break;
    2.19  
    2.20              case DeviceGroup_Protocol__payload_PR_groupKeys:
    2.21 +                // re-check uuid in case sync_uuid changed while in the queue
    2.22 +                if (strncmp(session->sync_uuid,
    2.23 +                            (const char *)msg->payload.choice.groupKeys.partner.user_id->buf,
    2.24 +                            msg->payload.choice.groupKeys.partner.user_id->size) != 0){
    2.25 +                    status = PEP_SYNC_ILLEGAL_MESSAGE;
    2.26 +                    goto error;
    2.27 +                }
    2.28 +                // no break
    2.29              case DeviceGroup_Protocol__payload_PR_groupUpdate:
    2.30              {
    2.31                  identity_list *group_keys = IdentityList_to_identity_list(