KeySync : fixed bug in sequence_value. How is that possible wasn't detected before ? ENGINE-188
authorEdouard Tisserant <edouard@pep-project.org>
Sat, 11 Mar 2017 14:50:05 +0100
branchENGINE-188
changeset 1636cc152225ec01
parent 1635 b23f60d69fb8
child 1647 f089d9e32e60
child 1650 39375af2cfb5
KeySync : fixed bug in sequence_value. How is that possible wasn't detected before ?
src/pEpEngine.c
src/sync_impl.c
     1.1 --- a/src/pEpEngine.c	Thu Mar 09 17:18:19 2017 +0100
     1.2 +++ b/src/pEpEngine.c	Sat Mar 11 14:50:05 2017 +0100
     1.3 @@ -172,7 +172,11 @@
     1.4      "select value, own from sequences where name = ?1 ;";
     1.5  
     1.6  static const char *sql_sequence_value3 = 
     1.7 -    "update sequences set value = ?2, own = (select own or ?3 from sequences where name = ?1) where name = ?1 ;";
     1.8 +    "insert or replace into sequences (name, value, own) "
     1.9 +    "values (?1, "
    1.10 +    "        ?2, "
    1.11 +    "       (select coalesce((select own or ?3 from sequences "
    1.12 +    "           where name = ?1), ?3))) ; ";
    1.13          
    1.14  // Revocation tracking
    1.15  static const char *sql_set_revoked =
     2.1 --- a/src/sync_impl.c	Thu Mar 09 17:18:19 2017 +0100
     2.2 +++ b/src/sync_impl.c	Sat Mar 11 14:50:05 2017 +0100
     2.3 @@ -643,7 +643,7 @@
     2.4                      // don't free message now that it is in the queue
     2.5                      goto free_userid;
     2.6                  }
     2.7 -                else if (status == PEP_OWN_SEQUENCE) {
     2.8 +                else if (status == PEP_OWN_SEQUENCE || status == PEP_SEQUENCE_VIOLATED) {
     2.9                      status = PEP_STATUS_OK;
    2.10                      discard = true;
    2.11                      goto free_all;