Merge with sync sequoia_windows
authorThomas
Wed, 05 Jun 2019 08:32:55 +0200
branchsequoia_windows
changeset 38079c8a6cc4eb8d
parent 3800 fb9769f33508
parent 3806 b9c98a86b791
child 3808 cc7a572c3e96
Merge with sync
src/pgp_sequoia.c
     1.1 --- a/src/pEpEngine.c	Mon Jun 03 07:44:56 2019 +0200
     1.2 +++ b/src/pEpEngine.c	Wed Jun 05 08:32:55 2019 +0200
     1.3 @@ -968,6 +968,7 @@
     1.4                  "   timestamp integer default (datetime('now')),\n"
     1.5                  "   primary key (address, user_id)\n"
     1.6                  ");\n"
     1.7 +                "create index if not exists identity_userid_addr on identity(address, user_id);\n"
     1.8                  "create table if not exists trust (\n"
     1.9                  "   user_id text not null\n"
    1.10                  "       references person (id)\n"
    1.11 @@ -1423,6 +1424,17 @@
    1.12                  if (status != PEP_STATUS_OK)
    1.13                      return status;
    1.14              }
    1.15 +            if (version < 12) {
    1.16 +                int_result = sqlite3_exec(
    1.17 +                    _session->db,
    1.18 +                    "create index if not exists identity_userid_addr on identity(address, user_id);\n"
    1.19 +                    ,
    1.20 +                    NULL,
    1.21 +                    NULL,
    1.22 +                    NULL
    1.23 +                );
    1.24 +                assert(int_result == SQLITE_OK);                
    1.25 +            }
    1.26          }        
    1.27          else { 
    1.28              // Version from DB was 0, it means this is initial setup.
     2.1 --- a/src/pgp_sequoia.c	Mon Jun 03 07:44:56 2019 +0200
     2.2 +++ b/src/pgp_sequoia.c	Wed Jun 05 08:32:55 2019 +0200
     2.3 @@ -865,15 +865,12 @@
     2.4  
     2.5      free(email);
     2.6      free(name);
     2.7 -    if (user_id_iter)
     2.8 -        pgp_user_id_binding_iter_free(user_id_iter);
     2.9 -    if (key_iter)
    2.10 -        pgp_tpk_key_iter_free(key_iter);
    2.11 +    pgp_user_id_binding_iter_free(user_id_iter);
    2.12 +    pgp_tpk_key_iter_free(key_iter);
    2.13      if (stmt)
    2.14        sqlite3_reset(stmt);
    2.15      free(tsk_buffer);
    2.16 -    if (tpk)
    2.17 -        pgp_tpk_free(tpk);
    2.18 +    pgp_tpk_free(tpk);
    2.19      free(fpr);
    2.20      pgp_fingerprint_free(pgp_fpr);
    2.21  
    2.22 @@ -1025,13 +1022,10 @@
    2.23          cookie->decrypted = 1;
    2.24  
    2.25      eol:
    2.26 -        if (sk)
    2.27 -            pgp_session_key_free (sk);
    2.28 +        pgp_session_key_free (sk);
    2.29          free(keyid_str);
    2.30 -        if (key_iter)
    2.31 -            pgp_tpk_key_iter_free(key_iter);
    2.32 -        if (tpk)
    2.33 -            pgp_tpk_free(tpk);
    2.34 +        pgp_tpk_key_iter_free(key_iter);
    2.35 +        pgp_tpk_free(tpk);
    2.36      }
    2.37  
    2.38      // Consider wildcard recipients.
    2.39 @@ -1104,11 +1098,9 @@
    2.40              key_iter = NULL;
    2.41          }
    2.42      eol2:
    2.43 -        if (sk)
    2.44 -            pgp_session_key_free (sk);
    2.45 +        pgp_session_key_free (sk);
    2.46          free(keyid_str);
    2.47 -        if (key_iter)
    2.48 -            pgp_tpk_key_iter_free(key_iter);
    2.49 +        pgp_tpk_key_iter_free(key_iter);
    2.50      }
    2.51  
    2.52      if (tsks) {
    2.53 @@ -1442,12 +1434,9 @@
    2.54          free(*ptext);
    2.55      }
    2.56  
    2.57 -    if (reader)
    2.58 -        pgp_reader_free(reader);
    2.59 -    if (decryptor)
    2.60 -        pgp_reader_free(decryptor);
    2.61 -    if (writer)
    2.62 -        pgp_writer_free(writer);
    2.63 +    pgp_reader_free(reader);
    2.64 +    pgp_reader_free(decryptor);
    2.65 +    pgp_writer_free(writer);
    2.66  
    2.67      T("-> %s", pEp_status_to_string(status));
    2.68      return status;
    2.69 @@ -1541,12 +1530,9 @@
    2.70          free_stringlist(cookie.signer_keylist);
    2.71      }
    2.72  
    2.73 -    if (verifier)
    2.74 -        pgp_reader_free(verifier);
    2.75 -    if (reader)
    2.76 -        pgp_reader_free(reader);
    2.77 -    if (dsig_reader)
    2.78 -        pgp_reader_free(dsig_reader);
    2.79 +    pgp_reader_free(verifier);
    2.80 +    pgp_reader_free(reader);
    2.81 +    pgp_reader_free(dsig_reader);
    2.82  
    2.83      T("-> %s", pEp_status_to_string(status));
    2.84      return status;
    2.85 @@ -1628,14 +1614,10 @@
    2.86      (*stext)[*ssize] = 0;
    2.87  
    2.88   out:
    2.89 -    if (signer)
    2.90 -        pgp_signer_free (signer);
    2.91 -    if (signing_keypair)
    2.92 -        pgp_key_pair_free (signing_keypair);
    2.93 -    if (iter)
    2.94 -        pgp_tpk_key_iter_free (iter);
    2.95 -    if (signer_tpk)
    2.96 -        pgp_tpk_free(signer_tpk);
    2.97 +    pgp_signer_free (signer);
    2.98 +    pgp_key_pair_free (signing_keypair);
    2.99 +    pgp_tpk_key_iter_free (iter);
   2.100 +    pgp_tpk_free(signer_tpk);
   2.101  
   2.102      T("(%s)-> %s", fpr, pEp_status_to_string(status));
   2.103      return status;
   2.104 @@ -1749,14 +1731,10 @@
   2.105      (*ctext)[*csize] = 0;
   2.106  
   2.107   out:
   2.108 -    if (signer)
   2.109 -        pgp_signer_free (signer);
   2.110 -    if (signing_keypair)
   2.111 -        pgp_key_pair_free (signing_keypair);
   2.112 -    if (iter)
   2.113 -        pgp_tpk_key_iter_free (iter);
   2.114 -    if (signer_tpk)
   2.115 -        pgp_tpk_free(signer_tpk);
   2.116 +    pgp_signer_free (signer);
   2.117 +    pgp_key_pair_free (signing_keypair);
   2.118 +    pgp_tpk_key_iter_free (iter);
   2.119 +    pgp_tpk_free(signer_tpk);
   2.120  
   2.121      for (int i = 0; i < keys_count; i ++)
   2.122          pgp_tpk_free(keys[i]);
   2.123 @@ -1808,7 +1786,7 @@
   2.124      size_t userid_len = 0;
   2.125      const uint8_t *raw = pgp_user_id_value(userid_packet, &userid_len);
   2.126  
   2.127 -    // Null terminate it.
   2.128 +    // NUL terminate it.
   2.129      userid = malloc(userid_len + 1);
   2.130      if (!userid)
   2.131          ERROR_OUT(NULL, PEP_OUT_OF_MEMORY, "out of memory");
   2.132 @@ -1842,14 +1820,11 @@
   2.133      fpr = NULL;
   2.134  
   2.135   out:
   2.136 -    if (pgp_fpr)
   2.137 -        pgp_fingerprint_free(pgp_fpr);
   2.138 +    pgp_fingerprint_free(pgp_fpr);
   2.139      free(fpr);
   2.140 -    if (tpk)
   2.141 -        pgp_tpk_free(tpk);
   2.142 +    pgp_tpk_free(tpk);
   2.143      free(userid);
   2.144 -    if (userid_packet)
   2.145 -        pgp_packet_free(userid_packet);
   2.146 +    pgp_packet_free(userid_packet);
   2.147  
   2.148      T("-> %s", pEp_status_to_string(status));
   2.149      return status;
   2.150 @@ -2003,8 +1978,7 @@
   2.151      }
   2.152  
   2.153   out:
   2.154 -    if (parser)
   2.155 -        pgp_tpk_parser_free(parser);
   2.156 +    pgp_tpk_parser_free(parser);
   2.157  
   2.158      T("-> %s", pEp_status_to_string(status));
   2.159      return status;
   2.160 @@ -2076,12 +2050,12 @@
   2.161      return status;
   2.162  }
   2.163  
   2.164 -char* _undot_address(const char* address) {
   2.165 +static char *_undot_address(const char* address) {
   2.166      if (!address)
   2.167          return NULL;
   2.168  
   2.169      int addr_len = strlen(address);
   2.170 -    const char* at = strstr(address, "@");
   2.171 +    const char* at = memchr(address, '@', addr_len);
   2.172  
   2.173      if (!at)
   2.174          at = address + addr_len;
   2.175 @@ -2230,10 +2204,8 @@
   2.176      }
   2.177  
   2.178   out:
   2.179 -    if (tpk)
   2.180 -        pgp_tpk_free(tpk);
   2.181 -    if (fpr)
   2.182 -        pgp_fingerprint_free(fpr);
   2.183 +    pgp_tpk_free(tpk);
   2.184 +    pgp_fingerprint_free(fpr);
   2.185  
   2.186      if (status == PEP_KEY_NOT_FOUND)
   2.187          status = PEP_STATUS_OK;
   2.188 @@ -2378,8 +2350,7 @@
   2.189      }
   2.190  
   2.191   out:
   2.192 -    if (tpk)
   2.193 -        pgp_tpk_free(tpk);
   2.194 +    pgp_tpk_free(tpk);
   2.195  
   2.196      T("(%s) -> %s", fpr, pEp_comm_type_to_string(*comm_type));
   2.197      return status;
   2.198 @@ -2439,14 +2410,10 @@
   2.199      ERROR_OUT(NULL, status, "Saving %s", fpr);
   2.200  
   2.201   out:
   2.202 -    if (signer)
   2.203 -        pgp_signer_free (signer);
   2.204 -    if (keypair)
   2.205 -        pgp_key_pair_free (keypair);
   2.206 -    if (iter)
   2.207 -        pgp_tpk_key_iter_free (iter);
   2.208 -    if (tpk)
   2.209 -        pgp_tpk_free(tpk);
   2.210 +    pgp_signer_free (signer);
   2.211 +    pgp_key_pair_free (keypair);
   2.212 +    pgp_tpk_key_iter_free (iter);
   2.213 +    pgp_tpk_free(tpk);
   2.214  
   2.215      T("(%s) -> %s", fpr, pEp_status_to_string(status));
   2.216      return status;
   2.217 @@ -2500,14 +2467,10 @@
   2.218      ERROR_OUT(NULL, status, "Saving %s", fpr);
   2.219  
   2.220   out:
   2.221 -    if (signer)
   2.222 -        pgp_signer_free (signer);
   2.223 -    if (keypair)
   2.224 -        pgp_key_pair_free (keypair);
   2.225 -    if (iter)
   2.226 -        pgp_tpk_key_iter_free (iter);
   2.227 -    if (tpk)
   2.228 -        pgp_tpk_free(tpk);
   2.229 +    pgp_signer_free (signer);
   2.230 +    pgp_key_pair_free (keypair);
   2.231 +    pgp_tpk_key_iter_free (iter);
   2.232 +    pgp_tpk_free(tpk);
   2.233  
   2.234      T("(%s) -> %s", fpr, pEp_status_to_string(status));
   2.235      return status;
   2.236 @@ -2564,8 +2527,7 @@
   2.237      *expired = !(can_encrypt && can_sign && can_certify);
   2.238  
   2.239   out:
   2.240 -    if (tpk)
   2.241 -        pgp_tpk_free(tpk);
   2.242 +    pgp_tpk_free(tpk);
   2.243      T("(%s) -> %s", fpr, pEp_status_to_string(status));
   2.244      return status;
   2.245  }
     3.1 --- a/test/src/SuiteMaker.cc	Mon Jun 03 07:44:56 2019 +0200
     3.2 +++ b/test/src/SuiteMaker.cc	Wed Jun 05 08:32:55 2019 +0200
     3.3 @@ -24,6 +24,7 @@
     3.4  #include "NoOwnIdentWritesOnDecryptTests.h"
     3.5  #include "LiteralFilenameTests.h"
     3.6  #include "I18nTests.h"
     3.7 +#include "Message2_1Tests.h"
     3.8  #include "IdentityListTests.h"
     3.9  #include "PgpBinaryTests.h"
    3.10  #include "SubkeyRatingEvalTests.h"
    3.11 @@ -39,6 +40,7 @@
    3.12  #include "KeyringImportTests.h"
    3.13  #include "EnterLeaveDeviceGroupTests.h"
    3.14  #include "SignOnlyTests.h"
    3.15 +#include "LotsOfKeysTests.h"
    3.16  #include "BCCTests.h"
    3.17  #include "Engine358Tests.h"
    3.18  #include "BlacklistAcceptNewKeyTests.h"
    3.19 @@ -87,6 +89,7 @@
    3.20      "NoOwnIdentWritesOnDecryptTests",
    3.21      "LiteralFilenameTests",
    3.22      "I18nTests",
    3.23 +    "Message2_1Tests",
    3.24      "IdentityListTests",
    3.25      "PgpBinaryTests",
    3.26      "SubkeyRatingEvalTests",
    3.27 @@ -102,6 +105,7 @@
    3.28      "KeyringImportTests",
    3.29      "EnterLeaveDeviceGroupTests",
    3.30      "SignOnlyTests",
    3.31 +    "LotsOfKeysTests",
    3.32      "BCCTests",
    3.33      "Engine358Tests",
    3.34      "BlacklistAcceptNewKeyTests",
    3.35 @@ -138,7 +142,7 @@
    3.36  };
    3.37  
    3.38  // This file is generated, so magic constants are ok.
    3.39 -int SuiteMaker::num_suites = 60;
    3.40 +int SuiteMaker::num_suites = 62;
    3.41  
    3.42  void SuiteMaker::suitemaker_build(const char* test_class_name, const char* test_home, Test::Suite** test_suite) {
    3.43      if (strcmp(test_class_name, "URIAddressTests") == 0)
    3.44 @@ -165,6 +169,8 @@
    3.45          *test_suite = new LiteralFilenameTests(test_class_name, test_home);
    3.46      else if (strcmp(test_class_name, "I18nTests") == 0)
    3.47          *test_suite = new I18nTests(test_class_name, test_home);
    3.48 +    else if (strcmp(test_class_name, "Message2_1Tests") == 0)
    3.49 +        *test_suite = new Message2_1Tests(test_class_name, test_home);
    3.50      else if (strcmp(test_class_name, "IdentityListTests") == 0)
    3.51          *test_suite = new IdentityListTests(test_class_name, test_home);
    3.52      else if (strcmp(test_class_name, "PgpBinaryTests") == 0)
    3.53 @@ -195,6 +201,8 @@
    3.54          *test_suite = new EnterLeaveDeviceGroupTests(test_class_name, test_home);
    3.55      else if (strcmp(test_class_name, "SignOnlyTests") == 0)
    3.56          *test_suite = new SignOnlyTests(test_class_name, test_home);
    3.57 +    else if (strcmp(test_class_name, "LotsOfKeysTests") == 0)
    3.58 +        *test_suite = new LotsOfKeysTests(test_class_name, test_home);
    3.59      else if (strcmp(test_class_name, "BCCTests") == 0)
    3.60          *test_suite = new BCCTests(test_class_name, test_home);
    3.61      else if (strcmp(test_class_name, "Engine358Tests") == 0)
     4.1 --- a/test/src/engine_tests/LotsOfKeysTests.cc	Mon Jun 03 07:44:56 2019 +0200
     4.2 +++ b/test/src/engine_tests/LotsOfKeysTests.cc	Wed Jun 05 08:32:55 2019 +0200
     4.3 @@ -139,7 +139,7 @@
     4.4  
     4.5  void LotsOfKeysTests::check() {
     4.6      struct tm tm;
     4.7 -    time_t t = time((time_t) NULL);
     4.8 +    time_t t = time((time_t *) NULL);
     4.9      localtime_r(&t, &tm);
    4.10      strftime(start_time, sizeof(start_time), "%Y%m%d-%H%M%S", &tm);
    4.11