[git] GpgOL - branch, master, updated. gpgol-2.3.0-31-g4bc8476

by Andre Heinecke cvs at cvs.gnupg.org
Thu Sep 13 11:14:41 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  4bc8476bd340a1c43052b4a3285a1dde582c0296 (commit)
       via  c2e2bc6fdf92c70d18286ef9393e2376c359ea0e (commit)
       via  78d93a44aaccd10ccb97c51fb3083f1dadfaab4b (commit)
       via  bdc87bbcff9345e142c1b645cce7bc76b52cee63 (commit)
       via  1bc390e66c7a8933bab3d0962d0e05b948ea802d (commit)
       via  e5a3717ab023f71b28c8d4caefdad0c72845020a (commit)
      from  a0671ccbb477e31d25547532004fa6fd16a29f78 (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 4bc8476bd340a1c43052b4a3285a1dde582c0296
Merge: a0671cc c2e2bc6
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Thu Sep 13 11:14:30 2018 +0200

    Merge branch 'STABLE-BRANCH-2-3'


commit c2e2bc6fdf92c70d18286ef9393e2376c359ea0e
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Thu Sep 13 11:12:46 2018 +0200

    Add disable async encryption as hidden option
    
    * src/mail.cpp (Mail::check_inline_response): Look
    at opt.sync_enc again.
    * src/main.c (read_options): Read hidden _syncEnc value
    to disable async encryption.
    
    --
    This might be useful for support when for someone encryption
    crashes in the async form.

diff --git a/src/mail.cpp b/src/mail.cpp
index 328989d..b06311f 100644
--- a/src/mail.cpp
+++ b/src/mail.cpp
@@ -3050,22 +3050,16 @@ Mail::setWindowEnabled_o (bool value)
 bool
 Mail::check_inline_response ()
 {
-#if 0 // Should be fixed
-
-/* Async sending might lead to crashes when the send invocation is done.
- * For now we treat every mail as an inline response to disable async
- * encryption. :-( For more details see: T3838 */
-
+  /* Async sending is known to cause instabilities. So we keep
+     a hidden option to disable it. */
   if (opt.sync_enc)
     {
       m_async_crypt_disabled = true;
       return m_async_crypt_disabled;
     }
-#endif
 
   m_async_crypt_disabled = false;
 
-
   LPDISPATCH attachments = get_oom_object (m_mailitem, "Attachments");
   if (attachments)
     {
diff --git a/src/main.c b/src/main.c
index 43a34f4..8b08030 100644
--- a/src/main.c
+++ b/src/main.c
@@ -283,7 +283,6 @@ read_options (void)
   opt.automation = get_conf_bool ("automation", 1);
   opt.autosecure = get_conf_bool ("autosecure", 1);
   opt.autotrust = get_conf_bool ("autotrust", 0);
-  opt.sync_enc = get_conf_bool ("syncEnc", 0);
   opt.smime_html_warn_shown = get_conf_bool ("smimeHtmlWarnShown", 0);
 
   if (!opt.automation)
@@ -294,6 +293,9 @@ read_options (void)
       opt.autoresolve = 0;
       opt.autotrust = 0;
     }
+
+  /* Hidden options  */
+  opt.sync_enc = get_conf_bool ("_syncEnc", 0);
 }
 
 

commit 78d93a44aaccd10ccb97c51fb3083f1dadfaab4b
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Thu Sep 13 11:07:56 2018 +0200

    Disable async encryption for mails with attachs
    
    * src/mail.cpp (check_inline_response): Disable async crypt
    if mail has attachments.
    * src/windowmessage.cpp (CRYPTO_DONE): Clarify that the
    fallback to MAPI is a very very last resort.
    
    --
    This commit sacrifices usability (async encryption) for
    stability. We now use the old sync crypt code when attachments
    are added to a crypto mail to avoid errors that occured
    for some attachments.
    As there does not appear to be a detectable pattern or
    value for which attachments the write in the second send
    fails we block async crypt for all attachments.
    
    GnuPG-Bug-Id: T4131

diff --git a/src/mail.cpp b/src/mail.cpp
index 720ec3f..328989d 100644
--- a/src/mail.cpp
+++ b/src/mail.cpp
@@ -3064,6 +3064,61 @@ Mail::check_inline_response ()
 #endif
 
   m_async_crypt_disabled = false;
+
+
+  LPDISPATCH attachments = get_oom_object (m_mailitem, "Attachments");
+  if (attachments)
+    {
+      /* This is horrible. But. For some kinds of attachments (we
+         got reports about Office attachments the write in the
+         send event triggered by our crypto done code fails with
+         an exception. There does not appear to be a detectable
+         pattern when this happens.
+         As we can't be sure and do not know for which attachments
+         this really happens we do not use async crypt for any
+         mails with attachments. :-/
+         Better be save (not crash) instead of nice (async).
+
+         TODO: Figure this out.
+
+         The log goes like this. We pass the send event. That triggers
+         a write, which we pass. And then that fails. So it looks like
+         moving to Outbox fails. Because we can save as much as we
+         like before that.
+
+         Using the IMessage::SubmitMessage MAPI interface works, but
+         as it is unstable in our current implementation we do not
+         want to use it.
+
+         mailitem-events.cpp:Invoke: Passing send event for mime-encrypted message 12B7C6E0.
+         application-events.cpp:Invoke: Unhandled Event: f002
+         mailitem-events.cpp:Invoke: Write : 0ED4D058
+         mailitem-events.cpp:Invoke: Passing write event.
+         oomhelp.cpp:invoke_oom_method_with_parms_type: Method 'Send' invokation failed: 0x80020009
+         oomhelp.cpp:dump_excepinfo: Exception:
+         wCode: 0x1000
+         wReserved: 0x0
+         source: Microsoft Outlook
+         desc: The operation failed.  The messaging interfaces have returned an unknown error. If the problem persists, restart Outlook.
+         help: null
+         helpCtx: 0x0
+         deferredFill: 00000000
+         scode: 0x80040119
+      */
+
+      int count = get_oom_int (attachments, "Count");
+      gpgol_release (attachments);
+
+      if (count)
+        {
+          m_async_crypt_disabled = true;
+          log_debug ("%s:%s: Detected attachments. "
+                     "Disabling async crypt due to T4131.",
+                     SRCNAME, __func__);
+          return m_async_crypt_disabled;
+        }
+   }
+
   LPDISPATCH app = GpgolAddin::get_instance ()->get_application ();
   if (!app)
     {
diff --git a/src/windowmessages.cpp b/src/windowmessages.cpp
index 9991eba..bb349b5 100644
--- a/src/windowmessages.cpp
+++ b/src/windowmessages.cpp
@@ -168,8 +168,14 @@ gpgol_window_proc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
               if (invoke_oom_method (mail->item (), "Send", NULL))
                 {
                   log_error ("%s:%s: Send failed for %p. "
-                             "Trying SubmitMessage instead.",
+                             "Trying SubmitMessage instead.\n"
+                             "This will likely crash.",
                              SRCNAME, __func__, mail);
+
+                  /* What we do here is similar to the T3656 workaround
+                     in mailitem-events.cpp. In our tests this works but
+                     is unstable. So we only use it as a very very last
+                     resort. */
                   auto mail_message = get_oom_base_message (mail->item());
                   if (!mail_message)
                     {

commit bdc87bbcff9345e142c1b645cce7bc76b52cee63
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Thu Sep 13 10:29:55 2018 +0200

    Add more mimetypes in infer_content_type
    
    * src/mimemaker.cpp (infer_content_type): Add more mime types.

diff --git a/src/mimemaker.cpp b/src/mimemaker.cpp
index 216acdf..7adb25b 100644
--- a/src/mimemaker.cpp
+++ b/src/mimemaker.cpp
@@ -582,6 +582,11 @@ infer_content_type (const char * /*data*/, size_t /*datalen*/,
       { 1, "deb",   "application/x-debian-package" },
       { 1, "dl",    "video/dl" },
       { 1, "doc",   "application/msword" },
+      { 1, "docx",  "application/vnd.openxmlformats-officedocument.wordprocessingml.document" },
+      { 1, "dot",   "application/msword" },
+      { 1, "dotx",  "application/vnd.openxmlformats-officedocument.wordprocessingml.template" },
+      { 1, "docm",  "application/application/vnd.ms-word.document.macroEnabled.12" },
+      { 1, "dotm",  "application/vnd.ms-word.template.macroEnabled.12" },
       { 1, "dv",    "video/dv" },
       { 1, "dvi",   "application/x-dvi" },
       { 1, "eml",   "message/rfc822" },
@@ -640,6 +645,15 @@ infer_content_type (const char * /*data*/, size_t /*datalen*/,
       { 1, "png",   "image/png" },
       { 1, "pps",   "application/vnd.ms-powerpoint" },
       { 1, "ppt",   "application/vnd.ms-powerpoint" },
+      { 1, "pot",   "application/vnd.ms-powerpoint" },
+      { 1, "ppa",   "application/vnd.ms-powerpoint" },
+      { 1, "pptx",  "application/vnd.openxmlformats-officedocument.presentationml.presentation" },
+      { 1, "potx",  "application/vnd.openxmlformats-officedocument.presentationml.template" },
+      { 1, "ppsx",  "application/vnd.openxmlformats-officedocument.presentationml.slideshow" },
+      { 1, "ppam",  "application/vnd.ms-powerpoint.addin.macroEnabled.12" },
+      { 1, "pptm",  "application/vnd.ms-powerpoint.presentation.macroEnabled.12" },
+      { 1, "potm",  "application/vnd.ms-powerpoint.template.macroEnabled.12" },
+      { 1, "ppsm",  "application/vnd.ms-powerpoint.slideshow.macroEnabled.12" },
       { 1, "prf",   "application/pics-rules" },
       { 1, "ps",    "application/postscript" },
       { 1, "qt",    "video/quicktime" },
@@ -668,7 +682,14 @@ infer_content_type (const char * /*data*/, size_t /*datalen*/,
       { 0, "xhtml", "application/xhtml+xml" },
       { 1, "xlb",   "application/vnd.ms-excel" },
       { 1, "xls",   "application/vnd.ms-excel" },
+      { 1, "xlsx",  "application/vnd.ms-excel" },
       { 1, "xlt",   "application/vnd.ms-excel" },
+      { 1, "xla",   "application/vnd.ms-excel" },
+      { 1, "xltx",  "application/vnd.openxmlformats-officedocument.spreadsheetml.template" },
+      { 1, "xlsm",  "application/vnd.ms-excel.sheet.macroEnabled.12" },
+      { 1, "xltm",  "application/vnd.ms-excel.template.macroEnabled.12" },
+      { 1, "xlam",  "application/vnd.ms-excel.addin.macroEnabled.12" },
+      { 1, "xlsb",  "application/application/vnd.ms-excel.sheet.binary.macroEnabled.12" },
       { 0, "xml",   "application/xml" },
       { 0, "xsl",   "application/xml" },
       { 0, "xul",   "application/vnd.mozilla.xul+xml" },

commit 1bc390e66c7a8933bab3d0962d0e05b948ea802d
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Fri Sep 7 10:28:11 2018 +0200

    Fix encoding of last line
    
    * src/mimedataprovider.cpp (get_body, get_html_body): Don't
    append raw undecoded data anymore.
    (MimeDataProvider::finalize): New. Parse the last unfinished data.
    * src/parsecontroller.cpp (ParseController::parse): Call
    finalize.
    
    --
    Before this a quoted printable line without a line feed at the
    end would not be decoded. Leading to a broken display.
    
    (cherry picked from commit a0671ccbb477e31d25547532004fa6fd16a29f78)

diff --git a/src/mimedataprovider.cpp b/src/mimedataprovider.cpp
index e869cc5..ba49428 100644
--- a/src/mimedataprovider.cpp
+++ b/src/mimedataprovider.cpp
@@ -1030,37 +1030,29 @@ MimeDataProvider::create_attachment()
   /* TODO handle encoding */
 }
 
-const std::string &MimeDataProvider::get_body ()
+void MimeDataProvider::finalize ()
 {
-  if (m_rawbuf.size())
+  if (m_rawbuf.size ())
     {
-      /* If there was some data left in the rawbuf this could
-         mean that some plaintext was not finished with a linefeed.
-         In that case we append it to the bodies. */
-      m_body += m_rawbuf;
-      m_html_body += m_rawbuf;
-      m_rawbuf.clear();
+      m_rawbuf += "\r\n";
+      size_t not_taken = collect_input_lines (m_rawbuf.c_str(),
+                                              m_rawbuf.size());
+      m_rawbuf.erase (0, m_rawbuf.size() - not_taken);
+      if (m_rawbuf.size ())
+        {
+          log_error ("%s:%s: Collect left data in buffer.\n",
+                     SRCNAME, __func__);
+        }
     }
+}
+
+const std::string &MimeDataProvider::get_body ()
+{
   return m_body;
 }
 
 const std::string &MimeDataProvider::get_html_body ()
 {
-  if (!m_has_html_body)
-    {
-      /* Don't do the last line handling if we don't
-         have html */
-      return m_html_body;
-    }
-  if (m_rawbuf.size())
-    {
-      /* If there was some data left in the rawbuf this could
-         mean that some plaintext was not finished with a linefeed.
-         In that case we append it to the bodies. */
-      m_body += m_rawbuf;
-      m_html_body += m_rawbuf;
-      m_rawbuf.clear();
-    }
   return m_html_body;
 }
 
diff --git a/src/mimedataprovider.h b/src/mimedataprovider.h
index 4841d73..40e1c18 100644
--- a/src/mimedataprovider.h
+++ b/src/mimedataprovider.h
@@ -118,6 +118,9 @@ public:
   const std::string &get_body_charset() const;
 
   void set_has_html_body(bool value) {m_has_html_body = value;}
+
+  /* Finalize the bodys */
+  void finalize ();
 private:
 #ifdef HAVE_W32_SYSTEM
   /* Collect the data from mapi. */
diff --git a/src/parsecontroller.cpp b/src/parsecontroller.cpp
index df5b8fe..82d10e7 100644
--- a/src/parsecontroller.cpp
+++ b/src/parsecontroller.cpp
@@ -519,6 +519,11 @@ ParseController::parse()
     }
   TRACEPOINT;
 
+  if (m_outputprovider)
+    {
+      m_outputprovider->finalize ();
+    }
+
   return;
 }
 

commit e5a3717ab023f71b28c8d4caefdad0c72845020a
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Fri Sep 7 09:56:35 2018 +0200

    Fix a possible crash when reactivating gpgol
    
    * src/gpgoladdin.cpp (GpgolAddin::invalidateRibbons)
    (GpgolAddin::addRibbon): New.
    (g_ribbon_uis): Removed.
    
    --
    This keeps the ribbon ui in a member variable so that they
    are cleared out when the GpgolAddin class is remvoved on
    unload.
    
    Fixes a potential crash when a user would activate gpgol
    after deactivating it in the same outlook session and
    stale ribbon ui pointers would be accessed.
    
    (cherry picked from commit 50c514d6bd6026076f5f467b7d8523dff2ce97aa)

diff --git a/src/gpgoladdin.cpp b/src/gpgoladdin.cpp
index e331b86..03baf95 100644
--- a/src/gpgoladdin.cpp
+++ b/src/gpgoladdin.cpp
@@ -63,8 +63,6 @@ ULONG addinLocks = 0;
 
 bool can_unload = false;
 
-static std::list<LPDISPATCH> g_ribbon_uis;
-
 static GpgolAddin * addin_instance = NULL;
 
 /* This is the main entry point for the addin
@@ -791,7 +789,7 @@ GpgolRibbonExtender::Invoke (DISPID dispid, REFIID riid, LCID lcid,
 
       case ID_ON_LOAD:
           {
-            g_ribbon_uis.push_back (parms->rgvarg[0].pdispVal);
+            GpgolAddin::get_instance ()->addRibbon (parms->rgvarg[0].pdispVal);
             return S_OK;
           }
       case ID_CMD_OPEN_OPTIONS:
@@ -1102,16 +1100,10 @@ GpgolRibbonExtender::GetCustomUI (BSTR RibbonID, BSTR * RibbonXml)
    Updated. Sadly we don't know which ribbon_ui needs updates
    so we have to invalidate everything.
 */
-void gpgoladdin_invalidate_ui ()
+void
+gpgoladdin_invalidate_ui ()
 {
-  std::list<LPDISPATCH>::iterator it;
-
-  for (it = g_ribbon_uis.begin(); it != g_ribbon_uis.end(); ++it)
-    {
-      log_debug ("%s:%s: Invalidating ribbon: %p",
-                 SRCNAME, __func__, *it);
-      invoke_oom_method (*it, "Invalidate", NULL);
-    }
+  GpgolAddin::get_instance ()->invalidateRibbons();
 }
 
 GpgolAddin *
@@ -1130,6 +1122,27 @@ GpgolAddin::get_instance ()
 }
 
 void
+GpgolAddin::invalidateRibbons()
+{
+  /* This can only be done in the main thread so no
+     need for locking or copying here. */
+  for (const auto it: m_ribbon_uis)
+    {
+      log_debug ("%s:%s: Invalidating ribbon: %p",
+                 SRCNAME, __func__, it);
+      invoke_oom_method (it, "Invalidate", NULL);
+    }
+  log_debug ("%s:%s: Invalidation done.",
+             SRCNAME, __func__);
+}
+
+void
+GpgolAddin::addRibbon (LPDISPATCH disp)
+{
+  m_ribbon_uis.push_back (disp);
+}
+
+void
 GpgolAddin::shutdown ()
 {
   if (m_shutdown)
diff --git a/src/gpgoladdin.h b/src/gpgoladdin.h
index 1641942..3627a01 100644
--- a/src/gpgoladdin.h
+++ b/src/gpgoladdin.h
@@ -217,6 +217,12 @@ public:
   std::shared_ptr<DispCache> get_dispcache () { return m_dispcache; }
   bool isShutdown() { return m_shutdown; };
 
+  /* Register a ribbon ui component */
+  void addRibbon (LPDISPATCH ribbon);
+
+  /* Invalidate the ribbons. */
+  void invalidateRibbons ();
+
 private:
   ULONG m_lRef;
   GpgolRibbonExtender* m_ribbonExtender;
@@ -231,6 +237,7 @@ private:
   HHOOK m_hook;
   std::vector<LPDISPATCH> m_explorerEventSinks;
   std::shared_ptr<DispCache> m_dispcache;
+  std::vector<LPDISPATCH> m_ribbon_uis;
 };
 
 class GpgolAddinFactory: public IClassFactory

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

Summary of changes:
 src/mail.cpp           | 63 ++++++++++++++++++++++++++++++++++++++++++++------
 src/main.c             |  4 +++-
 src/mimemaker.cpp      | 21 +++++++++++++++++
 src/windowmessages.cpp |  8 ++++++-
 4 files changed, 87 insertions(+), 9 deletions(-)


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




More information about the Gnupg-commits mailing list