ENGINE-345: fix to outgoing_message_rating - set to PEP_rating_unencrypted instead of unknown
authorKrista Bennett <krista@pep-project.org>
Mon, 29 Jan 2018 16:52:54 +0100
changeset 2466339399330a9b
parent 2464 44bfe558ce3a
child 2467 ef6bb2e8a84c
child 2468 3a10b4f8ba41
child 2472 ebe750121b3d
child 2476 5a4da2a7f99b
ENGINE-345: fix to outgoing_message_rating - set to PEP_rating_unencrypted instead of unknown
src/keymanagement.c
src/message_api.c
     1.1 --- a/src/keymanagement.c	Mon Jan 29 12:40:43 2018 +0100
     1.2 +++ b/src/keymanagement.c	Mon Jan 29 16:52:54 2018 +0100
     1.3 @@ -374,6 +374,9 @@
     1.4      if (status == PEP_STATUS_OK && !EMPTYSTR(stored_ident->fpr))
     1.5          return_id->fpr = strdup(stored_ident->fpr);
     1.6          
     1.7 +    // This is outside the if block ON PURPOSE - we return an empty FPR +
     1.8 +    // the reason why a key wasn't used in the comm_type string if we can't
     1.9 +    // find or use one.
    1.10      return_id->comm_type = stored_ident->comm_type;
    1.11                  
    1.12      // We patch the DB with the input username, but if we didn't have
     2.1 --- a/src/message_api.c	Mon Jan 29 12:40:43 2018 +0100
     2.2 +++ b/src/message_api.c	Mon Jan 29 16:52:54 2018 +0100
     2.3 @@ -2796,6 +2796,9 @@
     2.4      return ADD_TO_LOG(status);
     2.5  }
     2.6  
     2.7 +// Note: if comm_type_determine is false, it generally means that
     2.8 +// we were unable to get key information for anyone in the list,
     2.9 +// likely because a key is missing.
    2.10  static void _max_comm_type_from_identity_list(
    2.11          identity_list *identities,
    2.12          PEP_SESSION session,
    2.13 @@ -2813,8 +2816,17 @@
    2.14                  status = update_identity(session, il->ident);
    2.15              else
    2.16                  status = myself(session, il->ident);
    2.17 -            if (status == PEP_STATUS_OK)
    2.18 -            {
    2.19 +                
    2.20 +            // check for the return statuses which might not a representative
    2.21 +            // value in the comm_type
    2.22 +            if (status == PEP_ILLEGAL_VALUE || status == PEP_CANNOT_SET_PERSON ||
    2.23 +                status == PEP_CANNOT_FIND_IDENTITY) {
    2.24 +                // PEP_CANNOT_FIND_IDENTITY only comes back when we've really
    2.25 +                // got nothing from update_identity after applying the whole
    2.26 +                // heuristic
    2.27 +                *max_comm_type = PEP_ct_unknown;
    2.28 +            }
    2.29 +            else {
    2.30                  *max_comm_type = _get_comm_type(session, *max_comm_type,
    2.31                          il->ident);
    2.32                  *comm_type_determined = true;
    2.33 @@ -2854,8 +2866,11 @@
    2.34      _max_comm_type_from_identity_list(msg->bcc, session,
    2.35                                        &max_comm_type, &comm_type_determined);
    2.36  
    2.37 -    if (comm_type_determined == false)
    2.38 -        *rating = PEP_rating_undefined;
    2.39 +    if (comm_type_determined == false) {
    2.40 +        // likely means there was a massive screwup with no sender or recipient
    2.41 +        // keys, but regardless, this'll end up being unencrypted
    2.42 +        *rating = PEP_rating_unencrypted;
    2.43 +    }
    2.44      else
    2.45          *rating = _MAX(_rating(max_comm_type, PEP_rating_undefined),
    2.46                  PEP_rating_unencrypted);