part 2/3 of unencrypted subject (thank you, thomas!) sync
authorVolker Birk <vb@pep-project.org>
Fri, 20 Sep 2019 16:20:42 +0200
branchsync
changeset 4068d676b03d7759
parent 4067 79804ea86623
child 4069 a0dd3f3d0fb9
part 2/3 of unencrypted subject (thank you, thomas!)
src/message_api.c
sync/cond_act_sync.yml2
     1.1 --- a/src/message_api.c	Fri Sep 20 10:54:51 2019 +0200
     1.2 +++ b/src/message_api.c	Fri Sep 20 16:20:42 2019 +0200
     1.3 @@ -3360,6 +3360,13 @@
     1.4  
     1.5  }
     1.6  
     1.7 +static bool _have_extrakeys(stringlist_t *keylist)
     1.8 +{
     1.9 +    return keylist
    1.10 +        && keylist->value
    1.11 +        && keylist->value[0];
    1.12 +}
    1.13 +
    1.14  static PEP_STATUS _decrypt_message(
    1.15          PEP_SESSION session,
    1.16          message *src,
    1.17 @@ -3399,15 +3406,13 @@
    1.18      unsigned int minor_ver = 0;
    1.19      
    1.20      // Grab input flags
    1.21 -    bool reencrypt = (((*flags & PEP_decrypt_flag_untrusted_server) > 0) && *keylist && !EMPTYSTR((*keylist)->value));
    1.22 +    bool reencrypt = ((*flags & PEP_decrypt_flag_untrusted_server) &&
    1.23 +            (_have_extrakeys(*keylist) || session->unencrypted_subject));
    1.24      
    1.25      // We own this pointer, and we take control of *keylist if reencrypting.
    1.26      stringlist_t* extra = NULL;
    1.27 -    if (reencrypt) {
    1.28 -        if (*keylist) {
    1.29 -            extra = *keylist;
    1.30 -        }
    1.31 -    }
    1.32 +    if (reencrypt)
    1.33 +        extra = *keylist;
    1.34              
    1.35      *dst = NULL;
    1.36      *keylist = NULL;
    1.37 @@ -3929,7 +3934,7 @@
    1.38              }
    1.39          }
    1.40      }
    1.41 -    
    1.42 +
    1.43      // 4. Set up return values
    1.44      *dst = msg;
    1.45      *keylist = _keylist;
    1.46 @@ -3938,7 +3943,7 @@
    1.47      if (reencrypt) {
    1.48          if (decrypt_status == PEP_DECRYPTED || decrypt_status == PEP_DECRYPTED_AND_VERIFIED) {
    1.49              const char* sfpr = NULL;
    1.50 -            if (_keylist != NULL && !(EMPTYSTR(_keylist->value)))
    1.51 +            if (_have_extrakeys(*keylist))
    1.52                  sfpr = _keylist->value;
    1.53               
    1.54              if (sfpr && decrypt_status == PEP_DECRYPTED_AND_VERIFIED) {
    1.55 @@ -3981,6 +3986,13 @@
    1.56                          decrypt_status = PEP_CANNOT_REENCRYPT;
    1.57                  }
    1.58              }            
    1.59 +            else if (!_have_extrakeys(*keylist) && session->unencrypted_subject) {
    1.60 +                free(src->shortmsg);
    1.61 +                src->shortmsg = strdup(msg->shortmsg);
    1.62 +                assert(src->shortmsg);
    1.63 +                if (!src->shortmsg)
    1.64 +                    goto enomem;
    1.65 +            }
    1.66          }
    1.67      }
    1.68          
     2.1 --- a/sync/cond_act_sync.yml2	Fri Sep 20 10:54:51 2019 +0200
     2.2 +++ b/sync/cond_act_sync.yml2	Fri Sep 20 16:20:42 2019 +0200
     2.3 @@ -545,5 +545,5 @@
     2.4      if (!session->inject_sync_event)
     2.5          return PEP_SYNC_NO_INJECT_CALLBACK;
     2.6  
     2.7 -    session->inject_sync_event(SHUTDOWN, NULL);
     2.8 +    session->inject_sync_event((void *) SHUTDOWN, NULL);
     2.9  ||