merge "default" into my branch roker-linux
authorRoker <roker@pep-project.org>
Fri, 01 Jul 2016 11:00:13 +0200
branchroker-linux
changeset 787274c303a0c5a
parent 779 cecbd66421f6
parent 786 cd0c6d03e539
child 799 f60a61e7d403
merge "default" into my branch
     1.1 --- a/src/message_api.c	Thu Jun 30 15:08:21 2016 +0200
     1.2 +++ b/src/message_api.c	Fri Jul 01 11:00:13 2016 +0200
     1.3 @@ -1181,6 +1181,35 @@
     1.4      return status;
     1.5  }
     1.6  
     1.7 +static bool is_a_pEpmessage(const message *msg)
     1.8 +{
     1.9 +    for (stringpair_list_t *i = msg->opt_fields; i && i->value ; i=i->next) {
    1.10 +        if (strcasecmp(i->value->key, "X-pEp-Version") == 0)
    1.11 +            return true;
    1.12 +    }
    1.13 +    return false;
    1.14 +}
    1.15 +
    1.16 +// update comm_type to pEp_ct_pEp if needed
    1.17 +
    1.18 +static void _update_identity_for_incoming_message(
    1.19 +        PEP_SESSION session,
    1.20 +        const message *src
    1.21 +    )
    1.22 +{
    1.23 +    if (src->from && src->from->user_id && src->from->address) {
    1.24 +        update_identity(session, src->from);
    1.25 +        if (is_a_pEpmessage(src)
    1.26 +                && src->from->comm_type >= PEP_ct_OpenPGP_unconfirmed
    1.27 +                && src->from->comm_type != PEP_ct_pEp_unconfirmed
    1.28 +                && src->from->comm_type != PEP_ct_pEp)
    1.29 +        {
    1.30 +            src->from->comm_type |= PEP_ct_pEp_unconfirmed;
    1.31 +            update_identity(session, src->from);
    1.32 +        }
    1.33 +    }
    1.34 +}
    1.35 +
    1.36  DYNAMIC_API PEP_STATUS _decrypt_message(
    1.37          PEP_SESSION session,
    1.38          message *src,
    1.39 @@ -1217,9 +1246,7 @@
    1.40  
    1.41      // Update src->from in case we just imported a key
    1.42      // we would need to check signature
    1.43 -    if(src->from && src->from->user_id && src->from->address)
    1.44 -        update_identity(session, src->from);
    1.45 -
    1.46 +    _update_identity_for_incoming_message(session, src);
    1.47      PEP_cryptotech crypto = determine_encryption_format(src);
    1.48  
    1.49      *dst = NULL;
    1.50 @@ -1419,8 +1446,8 @@
    1.51  
    1.52              // Update msg->from in case we just imported a key
    1.53              // we would need to check signature
    1.54 -            if(msg->from && msg->from->user_id && msg->from->address)
    1.55 -                 update_identity(session, msg->from);
    1.56 +
    1.57 +            _update_identity_for_incoming_message(session, src);
    1.58              
    1.59              char *re_ptext = NULL;
    1.60              size_t re_psize;
     2.1 --- a/src/platform_windows.h	Thu Jun 30 15:08:21 2016 +0200
     2.2 +++ b/src/platform_windows.h	Fri Jul 01 11:00:13 2016 +0200
     2.3 @@ -33,6 +33,9 @@
     2.4  #ifndef strncasecmp
     2.5  #define strncasecmp(A, B, C) _strnicmp((A), (B), (C))
     2.6  #endif
     2.7 +#ifndef strcasecmp
     2.8 +#define strcasecmp(A, B) _stricmp((A), (B))
     2.9 +#endif
    2.10  #ifndef gmtime_r
    2.11  #define gmtime_r(A, B) gmtime_s((B), (A))
    2.12  #endif
     3.1 --- a/src/stringpair.c	Thu Jun 30 15:08:21 2016 +0200
     3.2 +++ b/src/stringpair.c	Fri Jul 01 11:00:13 2016 +0200
     3.3 @@ -98,6 +98,7 @@
     3.4          return stringpair_list_add(stringpair_list->next, value);
     3.5  
     3.6      if (stringpair_list->value == NULL) {
     3.7 +        assert(stringpair_list->next == NULL);
     3.8          stringpair_list->value = value;
     3.9          return stringpair_list;
    3.10      }
     4.1 --- a/src/stringpair.h	Thu Jun 30 15:08:21 2016 +0200
     4.2 +++ b/src/stringpair.h	Fri Jul 01 11:00:13 2016 +0200
     4.3 @@ -8,16 +8,16 @@
     4.4  
     4.5  
     4.6  typedef struct _stringpair_t {
     4.7 -    char * key;
     4.8 -    char * value;
     4.9 +    char * key;   // may point to "" but must not be NULL!
    4.10 +    char * value; // may point to "" but must not be NULL!
    4.11  } stringpair_t;
    4.12  
    4.13  
    4.14  // new_stringpair() - allocate new stringpair_t
    4.15  //
    4.16  //  parameters:
    4.17 -//      key (in)        utf-8 string used as key
    4.18 -//      value (in)      utf-8 string containing the value
    4.19 +//      key (in)        utf-8 string used as key; may point to "" but must not be NULL!
    4.20 +//      value (in)      utf-8 string containing the value; may point to "" but must not be NULL!
    4.21  //
    4.22  //  return value:
    4.23  //      pointer to stringpair_t or NULL on failure
    4.24 @@ -91,7 +91,7 @@
    4.25  //      pointer to last element in stringpair_list or NULL if out of memory
    4.26  //
    4.27  //  caveat:
    4.28 -//      the ownership of the value goes to the stringpair_list
    4.29 +//      the ownership of the value goes to the stringpair_list if add is successful
    4.30  
    4.31  DYNAMIC_API stringpair_list_t *stringpair_list_add(
    4.32          stringpair_list_t *stringpair_list,
     5.1 --- a/sync/gen_statemachine.ysl2	Thu Jun 30 15:08:21 2016 +0200
     5.2 +++ b/sync/gen_statemachine.ysl2	Fri Jul 01 11:00:13 2016 +0200
     5.3 @@ -72,7 +72,7 @@
     5.4  
     5.5          // driver
     5.6  
     5.7 -        PEP_STATUS fsm_«@name»_inject(
     5.8 +        DYNAMIC_API PEP_STATUS fsm_«@name»_inject(
     5.9                  PEP_SESSION session,
    5.10                  «@name»_event event,
    5.11                  Identity partner,
     6.1 --- a/test/message_api_test.cc	Thu Jun 30 15:08:21 2016 +0200
     6.2 +++ b/test/message_api_test.cc	Fri Jul 01 11:00:13 2016 +0200
     6.3 @@ -83,8 +83,14 @@
     6.4      assert(msg4);
     6.5      assert(keylist4);
     6.6      assert(color);
     6.7 +    PEP_comm_type ct = enc_msg2->from->comm_type;
     6.8 +    assert(ct == PEP_ct_pEp || ct == PEP_ct_pEp_unconfirmed);
     6.9 +
    6.10 +    free_stringpair_list(enc_msg2->opt_fields);
    6.11 +    enc_msg2->opt_fields = NULL;
    6.12  
    6.13      cout << "keys used:";
    6.14 +
    6.15      for (stringlist_t* kl4 = keylist4; kl4 && kl4->value; kl4 = kl4->next)
    6.16      {
    6.17          cout << " " << kl4->value;