[git] GpgOL - branch, master, updated. gpgol-2.3.0-71-g8c61617

by Andre Heinecke cvs at cvs.gnupg.org
Mon Oct 8 15:27:14 CEST 2018


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GnuPG extension for MS Outlook".

The branch, master has been updated
       via  8c61617886882ce720b884aca9d6fc3e2e1128c4 (commit)
       via  cf47f74df6534d340e7334227168c919596c542d (commit)
       via  9ccdc0cdc02583ba486535a24660cb94d5c5946f (commit)
       via  991ee4da98d431f3b5d1a59f9c9419f539931188 (commit)
      from  9bb552a9ede0c4a089961bcdf81d200145e731f1 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 8c61617886882ce720b884aca9d6fc3e2e1128c4
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Mon Oct 8 15:23:16 2018 +0200

    Use mail_map copies for all complex ops
    
    * src/mail.cpp (Mail::revertAllMails_o, Mail::wipeAllMails_o),
    (Mail::closeAllMails_o): Use copy of the mail map.
    
    --
    For any complex operation we can't hold the lock of the
    map for the operation as the map might be modified / accessed
    from a different thread to complete the operation.
    
    It should not be a big problem with these functions.

diff --git a/src/mail.cpp b/src/mail.cpp
index 82c9259..b50cf3d 100644
--- a/src/mail.cpp
+++ b/src/mail.cpp
@@ -1800,7 +1800,9 @@ Mail::revertAllMails_o ()
   int err = 0;
   std::map<LPDISPATCH, Mail *>::iterator it;
   gpgrt_lock_lock (&mail_map_lock);
-  for (it = s_mail_map.begin(); it != s_mail_map.end(); ++it)
+  auto mail_map_copy = s_mail_map;
+  gpgrt_lock_unlock (&mail_map_lock);
+  for (it = mail_map_copy.begin(); it != mail_map_copy.end(); ++it)
     {
       if (it->second->revert_o ())
         {
@@ -1817,7 +1819,6 @@ Mail::revertAllMails_o ()
           continue;
         }
     }
-  gpgrt_lock_unlock (&mail_map_lock);
   TRETURN err;
 }
 
@@ -1828,7 +1829,9 @@ Mail::wipeAllMails_o ()
   int err = 0;
   std::map<LPDISPATCH, Mail *>::iterator it;
   gpgrt_lock_lock (&mail_map_lock);
-  for (it = s_mail_map.begin(); it != s_mail_map.end(); ++it)
+  auto mail_map_copy = s_mail_map;
+  gpgrt_lock_unlock (&mail_map_lock);
+  for (it = mail_map_copy.begin(); it != mail_map_copy.end(); ++it)
     {
       if (it->second->wipe_o ())
         {
@@ -1836,7 +1839,6 @@ Mail::wipeAllMails_o ()
           err++;
         }
     }
-  gpgrt_lock_unlock (&mail_map_lock);
   TRETURN err;
 }
 

commit cf47f74df6534d340e7334227168c919596c542d
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Mon Oct 8 15:19:58 2018 +0200

    Fix deadlock when selecting encrypt
    
    * src/mail.cpp (Mail::locateAllCryptoRecipients_o): Use a copy
    of the mail map instead of a locked instance.
    
    --
    Locking the mail map for a complex operation is a bad
    idea. What happened here is that locateKeys_o can start
    different threads and those threads can use "Mail::isValidPtr" which
    uses the s_mail_map and locks it accordingly.
    So there is a deadlock.

diff --git a/src/mail.cpp b/src/mail.cpp
index 9796834..82c9259 100644
--- a/src/mail.cpp
+++ b/src/mail.cpp
@@ -3413,14 +3413,15 @@ Mail::locateAllCryptoRecipients_o ()
   TSTART;
   gpgrt_lock_lock (&mail_map_lock);
   std::map<LPDISPATCH, Mail *>::iterator it;
-  for (it = s_mail_map.begin(); it != s_mail_map.end(); ++it)
+  auto mail_map_copy = s_mail_map;
+  gpgrt_lock_unlock (&mail_map_lock);
+  for (it = mail_map_copy.begin(); it != mail_map_copy.end(); ++it)
     {
       if (it->second->needs_crypto_m ())
         {
           it->second->locateKeys_o ();
         }
     }
-  gpgrt_lock_unlock (&mail_map_lock);
   TRETURN;
 }
 

commit 9ccdc0cdc02583ba486535a24660cb94d5c5946f
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Mon Oct 8 15:07:45 2018 +0200

    Add option to do decryption synchronously
    
    * src/common_indep.h (syncDec): New option.
    * src/main.c (read_options): Read it.
    * src/mail.cpp (do_parsing): Do not use windowmessage signaling
    for parsing done.
    (Mail::decryptVerify_o): Call the parser synchronously.
    
    --
    This is very ugly but might help some users who are affected
    by regular crashes when reading crypto mail.

diff --git a/src/common_indep.h b/src/common_indep.h
index cfe5e28..73910f4 100644
--- a/src/common_indep.h
+++ b/src/common_indep.h
@@ -200,6 +200,7 @@ struct
   int automation;            /* General automation */
   int autotrust;             /* TOFU configured for GpgOL */
   int sync_enc;              /* Disabed async encryption */
+  int sync_dec;              /* Disabed async decryption */
   int prefer_smime;          /* S/MIME prefered when autoresolving */
   int smime_html_warn_shown; /* Flag to save if unsigned smime warning was shown */
   int autoretrieve;           /* Use --auto-key-retrieve. */
diff --git a/src/mail.cpp b/src/mail.cpp
index 9e1c8d2..9796834 100644
--- a/src/mail.cpp
+++ b/src/mail.cpp
@@ -832,7 +832,10 @@ do_parsing (LPVOID arg)
       TRETURN -1;
     }
   parser->parse();
-  do_in_ui_thread (PARSING_DONE, arg);
+  if (!opt.sync_dec)
+    {
+      do_in_ui_thread (PARSING_DONE, arg);
+    }
   gpgrt_lock_unlock (&parser_lock);
   unblockInv();
   TRETURN 0;
@@ -1146,17 +1149,26 @@ Mail::decryptVerify_o ()
                    SRCNAME, __func__, getSubject_o ().c_str(), m_parser.get());
   gpgol_release (cipherstream);
 
-  HANDLE parser_thread = CreateThread (NULL, 0, do_parsing, (LPVOID) this, 0,
-                                       NULL);
+  if (!opt.sync_dec)
+    {
+      HANDLE parser_thread = CreateThread (NULL, 0, do_parsing, (LPVOID) this, 0,
+                                           NULL);
 
-  if (!parser_thread)
+      if (!parser_thread)
+        {
+          log_error ("%s:%s: Failed to create decrypt / verify thread.",
+                     SRCNAME, __func__);
+        }
+      CloseHandle (parser_thread);
+      TRETURN 0;
+    }
+  else
     {
-      log_error ("%s:%s: Failed to create decrypt / verify thread.",
-                 SRCNAME, __func__);
+      /* Parse synchronously */
+      do_parsing ((LPVOID) this);
+      parsing_done ();
+      TRETURN 0;
     }
-  CloseHandle (parser_thread);
-
-  TRETURN 0;
 }
 
 void find_and_replace(std::string& source, const std::string &find,
diff --git a/src/main.c b/src/main.c
index e773cb6..73d8f04 100644
--- a/src/main.c
+++ b/src/main.c
@@ -334,7 +334,8 @@ read_options (void)
     }
 
   /* Hidden options  */
-  opt.sync_enc = get_conf_bool ("_syncEnc", 0);
+  opt.sync_enc = get_conf_bool ("syncEnc", 0);
+  opt.sync_dec = get_conf_bool ("syncDec", 0);
 }
 
 

commit 991ee4da98d431f3b5d1a59f9c9419f539931188
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Mon Oct 8 15:06:22 2018 +0200

    Log configuration settings
    
    * src/common.cpp (load_extension_value): Log settings.
    
    --
    This can be helpful understanding user logs.

diff --git a/src/common.cpp b/src/common.cpp
index a8d6369..f3ec09f 100644
--- a/src/common.cpp
+++ b/src/common.cpp
@@ -885,7 +885,14 @@ store_extension_value (const char *key, const char *val)
 int
 load_extension_value (const char *key, char **val)
 {
-  return load_config_value (HKEY_CURRENT_USER, GPGOL_REGPATH, key, val);
+  int ret = load_config_value (HKEY_CURRENT_USER, GPGOL_REGPATH, key, val);
+  if (val)
+    {
+      log_debug ("%s:%s: LoadReg '%s' val '%s'",
+                 SRCNAME, __func__, key ? key : "null",
+                 *val ? *val : "null");
+    }
+  return ret;
 }
 
 int

-----------------------------------------------------------------------

Summary of changes:
 src/common.cpp     |  9 ++++++++-
 src/common_indep.h |  1 +
 src/mail.cpp       | 45 ++++++++++++++++++++++++++++++---------------
 src/main.c         |  3 ++-
 4 files changed, 41 insertions(+), 17 deletions(-)


hooks/post-receive
-- 
GnuPG extension for MS Outlook
http://git.gnupg.org




More information about the Gnupg-commits mailing list