ENGINE-450: Fixes for 450 reintegrated, and fixed a mem bug that doesn't happen when you have a ton of keys, so it got missed before. ENGINE-450-MARK-II
authorKrista Bennett <krista@pep-project.org>
Tue, 31 Jul 2018 21:39:01 +0200
branchENGINE-450-MARK-II
changeset 27954bd160717c54
parent 2793 2f50ad059072
child 2796 91818b883629
ENGINE-450: Fixes for 450 reintegrated, and fixed a mem bug that doesn't happen when you have a ton of keys, so it got missed before.
src/pgp_gpg.c
test/include/GPGConfFixTests.h
test/src/EngineTestSuite.cc
test/src/engine_tests/GPGConfFixTests.cc
test/test_files/450_good_gpgagent_conf_0
test/test_files/450_good_gpgagent_conf_1
test/test_files/450_good_gpgagent_conf_2
test/test_files/450_good_gpgagent_conf_3
test/test_files/450_good_gpgagent_conf_4
test/test_files/450_good_gpgagent_conf_5
test/test_files/450_good_gpgagent_conf_6
     1.1 --- a/src/pgp_gpg.c	Tue Jul 31 11:11:25 2018 +0200
     1.2 +++ b/src/pgp_gpg.c	Tue Jul 31 21:39:01 2018 +0200
     1.3 @@ -142,6 +142,10 @@
     1.4                  }    
     1.5                  if (notkey)
     1.6                      continue;
     1.7 +                    
     1.8 +                if (num_found_keys >= num_keys)
     1.9 +                    found_keys = (str_ptr_and_bit*)realloc(found_keys, (num_found_keys + 1) * sizeof(str_ptr_and_bit));
    1.10 +                    
    1.11                  found_keys[num_found_keys].key = keypos; 	
    1.12                  found_keys[num_found_keys].bit = i;
    1.13                  num_found_keys++;     
     2.1 --- a/test/include/GPGConfFixTests.h	Tue Jul 31 11:11:25 2018 +0200
     2.2 +++ b/test/include/GPGConfFixTests.h	Tue Jul 31 21:39:01 2018 +0200
     2.3 @@ -24,6 +24,13 @@
     2.4          void check_conf_fix_broken_conf_old_db_4();
     2.5          void check_conf_fix_broken_conf_old_db_5();
     2.6          void check_conf_fix_broken_conf_old_db_6();        
     2.7 +        void check_conf_fix_broken_agent_conf_old_db_0();
     2.8 +        void check_conf_fix_broken_agent_conf_old_db_1();
     2.9 +        void check_conf_fix_broken_agent_conf_old_db_2();
    2.10 +        void check_conf_fix_broken_agent_conf_old_db_3();
    2.11 +        void check_conf_fix_broken_agent_conf_old_db_4();
    2.12 +        void check_conf_fix_broken_agent_conf_old_db_5();
    2.13 +        void check_conf_fix_broken_agent_conf_old_db_6();                
    2.14  };
    2.15  
    2.16  #endif
     3.1 --- a/test/src/EngineTestSuite.cc	Tue Jul 31 11:11:25 2018 +0200
     3.2 +++ b/test/src/EngineTestSuite.cc	Tue Jul 31 21:39:01 2018 +0200
     3.3 @@ -73,7 +73,7 @@
     3.4      success = system("gpgconf --kill all");
     3.5      if (success != 0)
     3.6          throw std::runtime_error("SETUP: Error when executing 'gpgconf --kill all'.");
     3.7 -    sleep(1); // hopefully enough time for the system to recognise that it is dead. *sigh*    
     3.8 + //   sleep(1); // hopefully enough time for the system to recognise that it is dead. *sigh*    
     3.9  
    3.10      if (stat(test_home.c_str(), &dirchk) == 0) {
    3.11          if (!S_ISDIR(dirchk.st_mode))
    3.12 @@ -197,4 +197,4 @@
    3.13  
    3.14  void EngineTestSuite::set_my_name() {
    3.15      my_name = typeid(*this).name();
    3.16 -}
    3.17 \ No newline at end of file
    3.18 +}
     4.1 --- a/test/src/engine_tests/GPGConfFixTests.cc	Tue Jul 31 11:11:25 2018 +0200
     4.2 +++ b/test/src/engine_tests/GPGConfFixTests.cc	Tue Jul 31 21:39:01 2018 +0200
     4.3 @@ -29,6 +29,21 @@
     4.4                                                                        static_cast<Func>(&GPGConfFixTests::check_conf_fix_broken_conf_old_db_5)));
     4.5      add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("GPGConfFixTests::check_conf_fix_broken_conf_old_db_6"),
     4.6                                                                        static_cast<Func>(&GPGConfFixTests::check_conf_fix_broken_conf_old_db_6)));                                                                      
     4.7 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("GPGConfFixTests::check_conf_fix_broken_agent_conf_old_db_0"),
     4.8 +                                                                      static_cast<Func>(&GPGConfFixTests::check_conf_fix_broken_agent_conf_old_db_0)));
     4.9 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("GPGConfFixTests::check_conf_fix_broken_agent_conf_old_db_1"),
    4.10 +                                                                      static_cast<Func>(&GPGConfFixTests::check_conf_fix_broken_agent_conf_old_db_1)));
    4.11 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("GPGConfFixTests::check_conf_fix_broken_agent_conf_old_db_2"),
    4.12 +                                                                      static_cast<Func>(&GPGConfFixTests::check_conf_fix_broken_agent_conf_old_db_2)));
    4.13 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("GPGConfFixTests::check_conf_fix_broken_agent_conf_old_db_3"),
    4.14 +                                                                      static_cast<Func>(&GPGConfFixTests::check_conf_fix_broken_agent_conf_old_db_3)));
    4.15 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("GPGConfFixTests::check_conf_fix_broken_agent_conf_old_db_4"),
    4.16 +                                                                      static_cast<Func>(&GPGConfFixTests::check_conf_fix_broken_agent_conf_old_db_4)));
    4.17 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("GPGConfFixTests::check_conf_fix_broken_agent_conf_old_db_5"),
    4.18 +                                                                      static_cast<Func>(&GPGConfFixTests::check_conf_fix_broken_agent_conf_old_db_5)));
    4.19 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("GPGConfFixTests::check_conf_fix_broken_agent_conf_old_db_6"),
    4.20 +                                                                      static_cast<Func>(&GPGConfFixTests::check_conf_fix_broken_agent_conf_old_db_6)));                                                                      
    4.21 +                                                                      
    4.22  }
    4.23  
    4.24  void GPGConfFixTests::setup() {
    4.25 @@ -115,3 +130,38 @@
    4.26      TEST_ASSERT(file_bytes_equal("test_files/427_fixed_gpg_conf_6", (temp_test_home + "/.gnupg/gpg.conf").c_str()));    
    4.27  }
    4.28  
    4.29 +void GPGConfFixTests::check_conf_fix_broken_agent_conf_old_db_0() {
    4.30 +    set_full_env(NULL, "test_files/450_bad_gpgagent_conf_0", "test_files/427_old_db");
    4.31 +    TEST_ASSERT(file_bytes_equal("test_files/450_good_gpgagent_conf_0", (temp_test_home + "/.gnupg/gpg-agent.conf").c_str()));
    4.32 +}
    4.33 +
    4.34 +void GPGConfFixTests::check_conf_fix_broken_agent_conf_old_db_1() {
    4.35 +    set_full_env(NULL, "test_files/450_bad_gpgagent_conf_1", "test_files/427_old_db");    
    4.36 +    TEST_ASSERT(file_bytes_equal("test_files/450_good_gpgagent_conf_1", (temp_test_home + "/.gnupg/gpg-agent.conf").c_str()));
    4.37 +    
    4.38 +}
    4.39 +
    4.40 +void GPGConfFixTests::check_conf_fix_broken_agent_conf_old_db_2() {
    4.41 +    set_full_env(NULL, "test_files/450_bad_gpgagent_conf_2", "test_files/427_old_db");        
    4.42 +    TEST_ASSERT(file_bytes_equal("test_files/450_good_gpgagent_conf_2", (temp_test_home + "/.gnupg/gpg-agent.conf").c_str()));    
    4.43 +}
    4.44 +
    4.45 +void GPGConfFixTests::check_conf_fix_broken_agent_conf_old_db_3() {
    4.46 +    set_full_env(NULL, "test_files/450_bad_gpgagent_conf_3", "test_files/427_old_db");    
    4.47 +    TEST_ASSERT(file_bytes_equal("test_files/450_good_gpgagent_conf_3", (temp_test_home + "/.gnupg/gpg-agent.conf").c_str()));    
    4.48 +}
    4.49 +
    4.50 +void GPGConfFixTests::check_conf_fix_broken_agent_conf_old_db_4() {
    4.51 +    set_full_env(NULL, "test_files/450_bad_gpgagent_conf_4", "test_files/427_old_db");        
    4.52 +    TEST_ASSERT(file_bytes_equal("test_files/450_good_gpgagent_conf_4", (temp_test_home + "/.gnupg/gpg-agent.conf").c_str()));    
    4.53 +}
    4.54 +
    4.55 +void GPGConfFixTests::check_conf_fix_broken_agent_conf_old_db_5() {
    4.56 +    set_full_env(NULL, "test_files/450_bad_gpgagent_conf_5", "test_files/427_old_db");        
    4.57 +    TEST_ASSERT(file_bytes_equal("test_files/450_good_gpgagent_conf_5", (temp_test_home + "/.gnupg/gpg-agent.conf").c_str()));    
    4.58 +}
    4.59 +
    4.60 +void GPGConfFixTests::check_conf_fix_broken_agent_conf_old_db_6() {
    4.61 +    set_full_env(NULL, "test_files/450_bad_gpgagent_conf_6", "test_files/427_old_db");        
    4.62 +    TEST_ASSERT(file_bytes_equal("test_files/450_good_gpgagent_conf_6", (temp_test_home + "/.gnupg/gpg-agent.conf").c_str()));    
    4.63 +}
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/test/test_files/450_good_gpgagent_conf_0	Tue Jul 31 21:39:01 2018 +0200
     5.3 @@ -0,0 +1,4 @@
     5.4 +default-cache-ttl 398749
     5.5 +personal-cipher-preferences AES 
     5.6 +no-emit-version
     5.7 +max-cache-ttl 1200
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/test/test_files/450_good_gpgagent_conf_1	Tue Jul 31 21:39:01 2018 +0200
     6.3 @@ -0,0 +1,6 @@
     6.4 +comment No Comment
     6.5 +keyid-format 0xlong
     6.6 +max-cache-ttl 300 
     6.7 +personal-cipher-preferences AES 
     6.8 +allow-freeform-uid
     6.9 +default-cache-ttl 300
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/test/test_files/450_good_gpgagent_conf_2	Tue Jul 31 21:39:01 2018 +0200
     7.3 @@ -0,0 +1,8 @@
     7.4 +comment No Commentallow-freeform-uid
     7.5 +keyid-format 0xlong
     7.6 +default-cache-ttl 1 
     7.7 +personal-cipher-preferences AES 
     7.8 +default_cache_ttl 1 
     7.9 +default_cache_ttl 1 
    7.10 +allow-freeform-uid
    7.11 +max-cache-ttl 1200
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/test/test_files/450_good_gpgagent_conf_3	Tue Jul 31 21:39:01 2018 +0200
     8.3 @@ -0,0 +1,6 @@
     8.4 +comment No Commentallow-freeform-uidallow-freeform-uid
     8.5 +keyid-format 0xlong
     8.6 +max-cache-ttl 12 
     8.7 +personal-cipher-preferences AES 
     8.8 +allow-freeform-uid
     8.9 +default-cache-ttl 300
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/test/test_files/450_good_gpgagent_conf_4	Tue Jul 31 21:39:01 2018 +0200
     9.3 @@ -0,0 +1,6 @@
     9.4 +comment No Commentallow-freeform-uidcert-digest-algo SHA256
     9.5 +default-cache-ttl 2000000-buttsallow-freeform-uid
     9.6 +keyid-format 0xlong
     9.7 +personal-cipher-preferences AES 
     9.8 +allow-freeform-uid
     9.9 +max-cache-ttl 1200
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/test/test_files/450_good_gpgagent_conf_5	Tue Jul 31 21:39:01 2018 +0200
    10.3 @@ -0,0 +1,5 @@
    10.4 +comment No Comment
    10.5 +max-cache-ttl 2000000
    10.6 +keyid-format 0xlong
    10.7 +default-cache-ttl 2000000 
    10.8 +personal-cipher-preferences AES 
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/test/test_files/450_good_gpgagent_conf_6	Tue Jul 31 21:39:01 2018 +0200
    11.3 @@ -0,0 +1,2 @@
    11.4 +max-cache-ttl 2000000
    11.5 +default-cache-ttl 300