own_identities_retrieve() bullet proof keysync
authorVolker Birk <vb@pep.foundation>
Tue, 23 Aug 2016 17:20:04 +0200
branchkeysync
changeset 1071dac72ee3e56b
parent 1070 f698bb2738e8
child 1072 710d0936541d
own_identities_retrieve() bullet proof
src/keymanagement.c
src/pEpEngine.c
src/sync_impl.c
     1.1 --- a/src/keymanagement.c	Tue Aug 23 17:08:26 2016 +0200
     1.2 +++ b/src/keymanagement.c	Tue Aug 23 17:20:04 2016 +0200
     1.3 @@ -737,16 +737,14 @@
     1.4                      sqlite3_column_text(session->own_identities_retrieve, 0);
     1.5                  fpr = (const char *)
     1.6                      sqlite3_column_text(session->own_identities_retrieve, 1);
     1.7 -                user_id = (const char *)
     1.8 +                user_id = PEP_OWN_USERID;
     1.9 +                username = (const char *)
    1.10                      sqlite3_column_text(session->own_identities_retrieve, 2);
    1.11 -                username = (const char *)
    1.12 +                comm_type = PEP_ct_pEp;
    1.13 +                lang = (const char *)
    1.14                      sqlite3_column_text(session->own_identities_retrieve, 3);
    1.15 -                comm_type = (PEP_comm_type)
    1.16 +                flags = (unsigned int)
    1.17                      sqlite3_column_int(session->own_key_is_listed, 4);
    1.18 -                lang = (const char *)
    1.19 -                    sqlite3_column_text(session->own_identities_retrieve, 5);
    1.20 -                flags = (unsigned int)
    1.21 -                    sqlite3_column_int(session->own_key_is_listed, 6);
    1.22  
    1.23                  pEp_identity *ident = new_identity(address, fpr, username, user_id);
    1.24                  ident->comm_type = comm_type;
     2.1 --- a/src/pEpEngine.c	Tue Aug 23 17:08:26 2016 +0200
     2.2 +++ b/src/pEpEngine.c	Tue Aug 23 17:20:04 2016 +0200
     2.3 @@ -360,8 +360,8 @@
     2.4                                  "   where main_key_id = upper(replace(?1,' ',''))"
     2.5                                  "    and user_id = '" PEP_OWN_USERID "' );";
     2.6  
     2.7 -        sql_own_identities_retrieve =  "select address, fpr, username, user_id,"
     2.8 -                            "   comm_type, lang, identity.flags | pgp_keypair.flags"
     2.9 +        sql_own_identities_retrieve =  "select address, fpr, username, "
    2.10 +                            "   lang, identity.flags | pgp_keypair.flags"
    2.11                              "   from identity"
    2.12                              "   join person on id = identity.user_id"
    2.13                              "   join pgp_keypair on fpr = identity.main_key_id"
     3.1 --- a/src/sync_impl.c	Tue Aug 23 17:08:26 2016 +0200
     3.2 +++ b/src/sync_impl.c	Tue Aug 23 17:20:04 2016 +0200
     3.3 @@ -152,10 +152,7 @@
     3.4  
     3.5      msg->header.state = (long) state;
     3.6  
     3.7 -    me = new_identity(partner->address, NULL, PEP_OWN_USERID, NULL);
     3.8 -    if (!me)
     3.9 -        goto enomem;
    3.10 -    status = myself(session, me);
    3.11 +    status = get_identity(session, partner->address, PEP_OWN_USERID, &me);
    3.12      if (status != PEP_STATUS_OK)
    3.13          goto error;
    3.14      if (Identity_from_Struct(me, &msg->header.me) == NULL)