target_id is mandatory sync
authorVolker Birk <vb@pep.foundation>
Sun, 21 Oct 2018 12:12:03 +0200
branchsync
changeset 308016fe89d2bc89
parent 3079 010b851a6262
child 3081 094fa0544427
target_id is mandatory
src/message_api.c
     1.1 --- a/src/message_api.c	Sun Oct 21 11:59:45 2018 +0200
     1.2 +++ b/src/message_api.c	Sun Oct 21 12:12:03 2018 +0200
     1.3 @@ -2147,11 +2147,12 @@
     1.4      message* _src = src;
     1.5  
     1.6      assert(session);
     1.7 +    assert(target_id);
     1.8      assert(src);
     1.9      assert(dst);
    1.10      assert(enc_format != PEP_enc_none);
    1.11  
    1.12 -    if (!(session && src && dst && enc_format != PEP_enc_none))
    1.13 +    if (!(session && target_id && src && dst && enc_format != PEP_enc_none))
    1.14          return PEP_ILLEGAL_VALUE;
    1.15  
    1.16      // if (src->dir == PEP_dir_incoming)
    1.17 @@ -2160,8 +2161,8 @@
    1.18      determine_encryption_format(src);
    1.19      if (src->enc_format != PEP_enc_none)
    1.20          return PEP_ILLEGAL_VALUE;
    1.21 -    if (target_id && (!target_id->user_id || target_id->user_id[0] == '\0')) {
    1.22 -        
    1.23 +
    1.24 +    if (!target_id->user_id || target_id->user_id[0] == '\0') {
    1.25          char* own_id = NULL;
    1.26          status = get_default_own_userid(session, &own_id);
    1.27          if (own_id) {
    1.28 @@ -2169,14 +2170,18 @@
    1.29              target_id->user_id = own_id; // ownership transfer
    1.30          }
    1.31      }
    1.32 -    
    1.33 +
    1.34 +    if (!target_id->user_id || target_id->user_id[0] == '\0')
    1.35 +        return PEP_CANNOT_FIND_IDENTITY;
    1.36 +
    1.37      if (target_id->address) {
    1.38          status = myself(session, target_id);
    1.39          if (status != PEP_STATUS_OK)
    1.40              goto pEp_error;
    1.41      }
    1.42 -    else if (!target_id->fpr)
    1.43 +    else if (!target_id->fpr) {
    1.44          return PEP_ILLEGAL_VALUE;
    1.45 +    }
    1.46      
    1.47      *dst = NULL;
    1.48