merged in default test_diphoton
authorKrista Bennett <krista@pep-project.org>
Tue, 24 Oct 2017 11:38:39 +0200
branchtest_diphoton
changeset 219427024582896d
parent 2181 9545178b557c
parent 2193 0dc7346c26fc
child 2196 e680ca5b914b
merged in default
src/message_api.c
     1.1 --- a/build-windows/pEpEngine.vcxproj	Sun Oct 22 16:52:57 2017 +0200
     1.2 +++ b/build-windows/pEpEngine.vcxproj	Tue Oct 24 11:38:39 2017 +0200
     1.3 @@ -43,12 +43,12 @@
     1.4    <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     1.5      <LinkIncremental>true</LinkIncremental>
     1.6      <RunCodeAnalysis>false</RunCodeAnalysis>
     1.7 -    <IncludePath>$(ProjectDir)\..\..\libetpan\build-windows\include;C:\Program Files %28x86%29\GNU\GnuPG\include;$(IncludePath);$(ProjectDir)\asn.1;%ASN1C%\share\asn1c</IncludePath>
     1.8 +	<IncludePath>$(ProjectDir)\..\..\libetpan\build-windows\include;C:\Program Files %28x86%29\Gpg4win\include;$(IncludePath);$(ProjectDir)\asn.1;%ASN1C%\share\asn1c</IncludePath>
     1.9      <LibraryPath>$(ProjectDir)\..\..\libetpan\build-windows\Debug;$(LibraryPath)</LibraryPath>
    1.10    </PropertyGroup>
    1.11    <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    1.12      <LinkIncremental>false</LinkIncremental>
    1.13 -    <IncludePath>$(ProjectDir)\..\..\libetpan\build-windows\include;C:\Program Files %28x86%29\GNU\GnuPG\include;$(IncludePath);$(ProjectDir)\asn.1;%ASN1C%\share\asn1c</IncludePath>
    1.14 +	<IncludePath>$(ProjectDir)\..\..\libetpan\build-windows\include;C:\Program Files %28x86%29\Gpg4win\include;$(IncludePath);$(ProjectDir)\asn.1;%ASN1C%\share\asn1c</IncludePath>
    1.15      <LibraryPath>$(ProjectDir)\..\..\libetpan\build-windows\Release;$(LibraryPath)</LibraryPath>
    1.16    </PropertyGroup>
    1.17    <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     2.1 --- a/src/message_api.c	Sun Oct 22 16:52:57 2017 +0200
     2.2 +++ b/src/message_api.c	Tue Oct 24 11:38:39 2017 +0200
     2.3 @@ -770,7 +770,7 @@
     2.4      PEP_STATUS status = PEP_STATUS_OK;
     2.5  
     2.6      replace_opt_field(attachment, "X-pEp-Version", PEP_VERSION);
     2.7 -
     2.8 +        
     2.9      if (!_envelope) {
    2.10          _envelope = extract_minimal_envelope(attachment, PEP_dir_outgoing);
    2.11          status = generate_message_id(_envelope);
    2.12 @@ -787,13 +787,20 @@
    2.13          _envelope->longmsg = encapsulate_message_wrap_info("TRANSPORT", _envelope->longmsg);
    2.14      }
    2.15      char* message_text = NULL;
    2.16 +
    2.17 +    /* prevent introduction of pEp in inner message */
    2.18 +
    2.19 +    if (!attachment->shortmsg) {
    2.20 +        attachment->shortmsg = strdup("");
    2.21 +        if (!attachment->shortmsg)
    2.22 +            goto enomem;
    2.23 +    }
    2.24 +            
    2.25      /* Turn message into a MIME-blob */
    2.26      status = mime_encode_message(attachment, false, &message_text);
    2.27 -    
    2.28 -    if (status != PEP_STATUS_OK) {
    2.29 -        free(_envelope);
    2.30 -        return NULL;
    2.31 -    }
    2.32 +        
    2.33 +    if (status != PEP_STATUS_OK)
    2.34 +        goto enomem;
    2.35      
    2.36      size_t message_len = strlen(message_text);
    2.37      
    2.38 @@ -804,6 +811,12 @@
    2.39      if (keep_orig_subject && attachment->shortmsg)
    2.40          _envelope->shortmsg = strdup(attachment->shortmsg);
    2.41      return _envelope;
    2.42 +    
    2.43 +enomem:
    2.44 +    if (!envelope) {
    2.45 +        free(_envelope);
    2.46 +    }
    2.47 +    return NULL;    
    2.48  }
    2.49  
    2.50  static PEP_STATUS encrypt_PGP_MIME(
    2.51 @@ -1513,8 +1526,6 @@
    2.52      return ADD_TO_LOG(status);
    2.53  }
    2.54  
    2.55 -
    2.56 -// FIXME: Update if needed for the wrapped fun bits
    2.57  DYNAMIC_API PEP_STATUS encrypt_message_for_self(
    2.58          PEP_SESSION session,
    2.59          pEp_identity* target_id,
    2.60 @@ -1527,6 +1538,7 @@
    2.61      PEP_STATUS status = PEP_STATUS_OK;
    2.62      message * msg = NULL;
    2.63      stringlist_t * keys = NULL;
    2.64 +    message* _src = src;
    2.65  
    2.66      assert(session);
    2.67      assert(src);
    2.68 @@ -1566,24 +1578,20 @@
    2.69      if (!(flags & PEP_encrypt_flag_force_no_attached_key))
    2.70          _attach_key(session, target_fpr, src);
    2.71  
    2.72 -    msg = clone_to_empty_message(src);
    2.73 +    _src = wrap_message_as_attachment(NULL, src, session->unencrypted_subject);
    2.74 +    if (!_src)
    2.75 +        goto pep_error;
    2.76 +
    2.77 +    msg = clone_to_empty_message(_src);
    2.78      if (msg == NULL)
    2.79          goto enomem;
    2.80  
    2.81      switch (enc_format) {
    2.82          case PEP_enc_PGP_MIME:
    2.83          case PEP_enc_PEP: // BUG: should be implemented extra
    2.84 -            status = encrypt_PGP_MIME(session, src, keys, msg, flags);
    2.85 +            status = encrypt_PGP_MIME(session, _src, keys, msg, flags);
    2.86              break;
    2.87  
    2.88 -        // case PEP_enc_pieces:
    2.89 -        //     status = encrypt_PGP_in_pieces(session, src, keys, msg, flags);
    2.90 -        //     break;
    2.91 -
    2.92 -        /* case PEP_enc_PEP:
    2.93 -            NOT_IMPLEMENTED */
    2.94 -            // TODO: implement
    2.95 -
    2.96          default:
    2.97              assert(0);
    2.98              status = PEP_ILLEGAL_VALUE;
    2.99 @@ -1604,8 +1612,8 @@
   2.100       }
   2.101  
   2.102       if (msg) {
   2.103 -         if (src->id) {
   2.104 -             msg->id = strdup(src->id);
   2.105 +         if (_src->id) {
   2.106 +             msg->id = strdup(_src->id);
   2.107               assert(msg->id);
   2.108               if (msg->id == NULL)
   2.109                   goto enomem;
   2.110 @@ -1613,6 +1621,10 @@
   2.111       }
   2.112  
   2.113      *dst = msg;
   2.114 +    
   2.115 +    if (src != _src)
   2.116 +        free_message(_src);
   2.117 +
   2.118      return status;
   2.119  
   2.120  enomem:
   2.121 @@ -1621,6 +1633,8 @@
   2.122  pep_error:
   2.123      free_stringlist(keys);
   2.124      free_message(msg);
   2.125 +    if (src != _src)
   2.126 +        free_message(_src);
   2.127  
   2.128      return ADD_TO_LOG(status);
   2.129  }
     3.1 --- a/src/mime.c	Sun Oct 22 16:52:57 2017 +0200
     3.2 +++ b/src/mime.c	Tue Oct 24 11:38:39 2017 +0200
     3.3 @@ -1091,7 +1091,7 @@
     3.4          text = NULL;
     3.5      }
     3.6  
     3.7 -    return _sl;
     3.8 +    return sl;
     3.9  
    3.10  enomem:
    3.11      free_stringlist(sl);