[git] GpgOL - branch, master, updated. gpgol-2.0.3-13-g093da39

by Andre Heinecke cvs at cvs.gnupg.org
Tue Nov 28 14:11:42 CET 2017


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  093da39ab37307e5b80dac4d58943f6a1518bb69 (commit)
       via  bf3c0200633f39f514657f83f39a9fe56455a76d (commit)
       via  c080254e3897ef457c2feec9dd8dd28c3481cca0 (commit)
      from  d21d404bb975c814809b6570f5a6628086178ead (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 093da39ab37307e5b80dac4d58943f6a1518bb69
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Tue Nov 28 13:57:17 2017 +0100

    Handle ms-tnef classified PGP/Inline mails
    
    * src/mail.cpp (get_attachment_stream): Add fallback
    if attachment count is zero even if we think it's ciphered.
    * src/mapihelp.cpp (get_internetcharsetbody_tag): Not
    getting internet charset body happens for ms-tnef. Debug only.
    (get_msgcls_from_pgp_lines): Use mapi_get_body_as_stream.
    (change_message_class_ipm_note): Look into application/ms-tnef.
    
    --
    Some mails have content type ms-tnef but PGP/Inline body.
    For those mails it also does not work to access our created
    MOSS attachment trough OOM. So we now handle that and use
    the MAPI Body directly.
    
    GnuPG-Bug-Id: T3419

diff --git a/src/mail.cpp b/src/mail.cpp
index 1c690bc..20d9343 100644
--- a/src/mail.cpp
+++ b/src/mail.cpp
@@ -406,9 +406,36 @@ get_attachment_stream (LPDISPATCH mailitem, int pos)
       return NULL;
     }
   LPDISPATCH attachment = get_attachment (mailitem, pos);
-  LPATTACH mapi_attachment = NULL;
   LPSTREAM stream = NULL;
 
+  if (!attachment)
+    {
+      // For opened messages that have ms-tnef type we
+      // create the moss attachment but don't find it
+      // in the OOM. Try to find it through MAPI.
+      HRESULT hr;
+      log_debug ("%s:%s: Failed to find MOSS Attachment. "
+                 "Fallback to MAPI.", SRCNAME, __func__);
+      LPMESSAGE message = get_oom_message (mailitem);
+      if (!message)
+        {
+          log_debug ("%s:%s: Failed to get MAPI Interface.",
+                     SRCNAME, __func__);
+          return NULL;
+        }
+      hr = message->OpenProperty (PR_BODY_A, &IID_IStream, 0, 0,
+                                  (LPUNKNOWN*)&stream);
+      if (hr)
+        {
+          log_debug ("%s:%s: OpenProperty failed: hr=%#lx",
+                     SRCNAME, __func__, hr);
+          return NULL;
+        }
+      return stream;
+    }
+
+  LPATTACH mapi_attachment = NULL;
+
   mapi_attachment = (LPATTACH) get_oom_iunknown (attachment,
                                                  "MapiObject");
   gpgol_release (attachment);
@@ -559,7 +586,7 @@ copy_attachment_to_file (std::shared_ptr<Attachment> att, HANDLE hFile)
   return 0;
 }
 
-/** Sets some meta data on the last attachment atted. The meta
+/** Sets some meta data on the last attachment added. The meta
   data is taken from the attachment object. */
 static int
 fixup_last_attachment (LPDISPATCH mail, std::shared_ptr<Attachment> attachment)
diff --git a/src/mapihelp.cpp b/src/mapihelp.cpp
index 1c3a5f6..f2c00f7 100644
--- a/src/mapihelp.cpp
+++ b/src/mapihelp.cpp
@@ -265,7 +265,7 @@ get_internetcharsetbody_tag (LPMESSAGE message, ULONG *r_tag)
     proparr = NULL;
   if (FAILED (hr) || !(proparr->aulPropTag[0] & 0xFFFF0000) ) 
     {
-      log_error ("%s:%s: can't get the Internet Charset Body property:"
+      log_debug ("%s:%s: can't get the Internet Charset Body property:"
                  " hr=%#lx\n", SRCNAME, __func__, hr); 
       result = -1;
     }
@@ -604,39 +604,30 @@ get_msgcls_from_pgp_lines (LPMESSAGE message)
   char *body = NULL;
   char *p;
   char *msgcls = NULL;
-  ULONG tag;
-  int   is_binary = 0;
+  int is_wchar = 0;
 
   if (!opt.mime_ui)
     {
       return NULL;
     }
 
-  hr = 0;
-  if (!get_internetcharsetbody_tag (message, &tag) )
-    {
-      hr = message->OpenProperty (tag, &IID_IStream, 0, 0, 
-                                  (LPUNKNOWN*)&stream);
-      if (!hr)
-        is_binary = 1;
-    }
-  else
+  stream = mapi_get_body_as_stream (message);
+  if (!stream)
     {
-      log_debug ("%s:%s: Failed to get body tag.",
+      log_debug ("%s:%s: Failed to get body ASCII stream.",
                  SRCNAME, __func__);
-      return NULL;
-    }
-  if (hr)
-    {
-      tag = PR_BODY;
-      hr = message->OpenProperty (tag, &IID_IStream, 0, 0, 
+      hr = message->OpenProperty (PR_BODY_W, &IID_IStream, 0, 0,
                                   (LPUNKNOWN*)&stream);
-    }
-  if (hr)
-    {
-      log_debug ("%s:%s: OpenProperty(%lx) failed: hr=%#lx",
-                 SRCNAME, __func__, tag, hr);
-      return NULL;
+      if (hr)
+        {
+          log_error ("%s:%s: Failed to get  w_body stream. : hr=%#lx",
+                     SRCNAME, __func__, hr);
+          return NULL;
+        }
+      else
+        {
+          is_wchar = 1;
+        }
     }
 
   hr = stream->Stat (&statInfo, STATFLAG_NONAME);
@@ -646,7 +637,7 @@ get_msgcls_from_pgp_lines (LPMESSAGE message)
       gpgol_release (stream);
       return NULL;
     }
-  
+
   /* We read only the first 1k to decide whether this is actually an
      OpenPGP armored message .  */
   nbytes = (size_t)statInfo.cbSize.QuadPart;
@@ -666,14 +657,14 @@ get_msgcls_from_pgp_lines (LPMESSAGE message)
   if (nread != nbytes)
     {
       log_debug ("%s:%s: not enough bytes returned\n", SRCNAME, __func__);
-      
+
       xfree (body);
       gpgol_release (stream);
       return NULL;
     }
   gpgol_release (stream);
 
-  if (!is_binary)
+  if (is_wchar)
     {
       char *tmp;
       tmp = wchar_to_utf8 ((wchar_t*)body);
@@ -988,7 +979,8 @@ change_message_class_ipm_note (LPMESSAGE message)
            !strcmp (ct, "multipart/mixed") ||
            !strcmp (ct, "multipart/alternative") ||
            !strcmp (ct, "multipart/related") ||
-           !strcmp (ct, "text/html"))
+           !strcmp (ct, "text/html") ||
+           !strcmp (ct, "application/ms-tnef"))
     {
       /* It is quite common to have a multipart/mixed or alternative
          mail with separate encrypted PGP parts.  Look at the body to

commit bf3c0200633f39f514657f83f39a9fe56455a76d
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Tue Nov 28 13:54:29 2017 +0100

    Abort attachment open early if attachment count 0
    
    * src/mail.cpp (get_attachment): Abort earlier if
    attachment count is zero.

diff --git a/src/mail.cpp b/src/mail.cpp
index e2e9ca5..1c690bc 100644
--- a/src/mail.cpp
+++ b/src/mail.cpp
@@ -291,6 +291,13 @@ get_attachment (LPDISPATCH mailitem, int pos)
 
   std::string item_str;
   int count = get_oom_int (attachments, "Count");
+  if (count < 1)
+    {
+      log_debug ("%s:%s: Invalid attachment count: %i.",
+                 SRCNAME, __func__, count);
+      gpgol_release (attachments);
+      return NULL;
+    }
   if (pos > 0)
     {
       item_str = std::string("Item(") + std::to_string(pos) + ")";
@@ -299,13 +306,6 @@ get_attachment (LPDISPATCH mailitem, int pos)
     {
       item_str = std::string("Item(") + std::to_string(count) + ")";
     }
-  if (count < 1)
-    {
-      log_debug ("%s:%s: Invalid attachment count: %i.",
-                 SRCNAME, __func__, count);
-      gpgol_release (attachments);
-      return NULL;
-    }
   attachment = get_oom_object (attachments, item_str.c_str());
   gpgol_release (attachments);
 

commit c080254e3897ef457c2feec9dd8dd28c3481cca0
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Tue Nov 28 13:53:17 2017 +0100

    Minor spacing issue in german translation
    
    * po/de.po: Fix minor spacing issue.

diff --git a/po/de.po b/po/de.po
index 028116a..7326ddc 100644
--- a/po/de.po
+++ b/po/de.po
@@ -985,7 +985,7 @@ msgstr ""
 
 #: src/parsecontroller.cpp:196
 msgid "Could not decrypt the data: "
-msgstr "Daten konnten nicht entschlüsselt werden:"
+msgstr "Daten konnten nicht entschlüsselt werden: "
 
 #: src/parsecontroller.cpp:203 src/parsecontroller.cpp:258
 msgid "Encrypted message (decryption not possible)"

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

Summary of changes:
 po/de.po         |  2 +-
 src/mail.cpp     | 45 ++++++++++++++++++++++++++++++++++++---------
 src/mapihelp.cpp | 50 +++++++++++++++++++++-----------------------------
 3 files changed, 58 insertions(+), 39 deletions(-)


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




More information about the Gnupg-commits mailing list