[git] GpgOL - branch, master, updated. gpgol-2.2.0-93-gaaafbc7

by Andre Heinecke cvs at cvs.gnupg.org
Fri Jul 20 15:01:38 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  aaafbc793741fc64abe02af90f22e095e3133319 (commit)
       via  a73aa07de8a1a36a8cc7f412635c1c10737be6fa (commit)
       via  02d0a5ba491ce6f075f3d3d195bc0894d8d7b45d (commit)
       via  e53cbd17a7ea130f4cfac47858a5c1445c0fefb6 (commit)
       via  52e5891158e99fa532b02d1a13ff17566a7d583a (commit)
       via  6bbd203bc201f90b0394af24c105fa187f33ae6f (commit)
       via  ad00070325e7f42380f9adeb27ac2a1a498c3e6a (commit)
       via  aea2712f472a25c1a85906bcb0400ef3779771dd (commit)
      from  2116eb9008fd93506686219cbdb332b8c29f303e (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 aaafbc793741fc64abe02af90f22e095e3133319
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Fri Jul 20 15:00:05 2018 +0200

    Add tracing for update body
    
    * src/mail.cpp (Mail::updateBody_o): Trace calls.
    
    --
    This seems to hang sometimes so lets make sure that it
    is actually the oom call that hangs.

diff --git a/src/mail.cpp b/src/mail.cpp
index a72bc3d..b7c6e02 100644
--- a/src/mail.cpp
+++ b/src/mail.cpp
@@ -1174,8 +1174,10 @@ Mail::updateBody_o ()
 
           char *converted = ansi_charset_to_utf8 (charset.c_str(), html.c_str(),
                                                   html.size(), codepage);
+          TRACEPOINT;
           int ret = put_oom_string (m_mailitem, "HTMLBody", converted ?
                                                             converted : "");
+          TRACEPOINT;
           xfree (converted);
           if (ret)
             {
@@ -1293,7 +1295,9 @@ Mail::updateBody_o ()
   char *converted = ansi_charset_to_utf8 (plain_charset.c_str(),
                                           body.c_str(), body.size(),
                                           codepage);
+  TRACEPOINT;
   int ret = put_oom_string (m_mailitem, "Body", converted ? converted : "");
+  TRACEPOINT;
   xfree (converted);
   if (ret)
     {

commit a73aa07de8a1a36a8cc7f412635c1c10737be6fa
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Fri Jul 20 14:58:15 2018 +0200

    Print error if addin is accessed after shutdown
    
    * src/gpgoladdin.cpp (GpgolAddin::get_instace): Print error
    when accessed.
    
    --
    I thought this might be happening.

diff --git a/src/gpgoladdin.cpp b/src/gpgoladdin.cpp
index cf75cc1..5adfb20 100644
--- a/src/gpgoladdin.cpp
+++ b/src/gpgoladdin.cpp
@@ -1117,6 +1117,11 @@ GpgolAddin::get_instance ()
     {
       addin_instance = new GpgolAddin ();
     }
+  if (addin_instance->isShutdown ())
+    {
+      log_error ("%s:%s: Get instance after shutdown",
+                 SRCNAME, __func__);
+    }
   return addin_instance;
 }
 
diff --git a/src/gpgoladdin.h b/src/gpgoladdin.h
index e2ae977..a8c121b 100644
--- a/src/gpgoladdin.h
+++ b/src/gpgoladdin.h
@@ -212,6 +212,7 @@ public:
      crypto mails. */
   void shutdown ();
   LPDISPATCH get_application () { return m_application; }
+  bool isShutdown() { return m_shutdown; };
 
 private:
   ULONG m_lRef;

commit 02d0a5ba491ce6f075f3d3d195bc0894d8d7b45d
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Fri Jul 20 14:57:34 2018 +0200

    Implement cpp ctor / dtor counting
    
    * src/memdbg.cpp (memdbg_ctor, memdbg_dtor): Implement.

diff --git a/src/memdbg.cpp b/src/memdbg.cpp
index 4f26fa6..3f68ae1 100644
--- a/src/memdbg.cpp
+++ b/src/memdbg.cpp
@@ -158,19 +158,66 @@ memdbg_released (void *obj)
 void
 memdbg_ctor (const char *objName)
 {
-  (void)objName;
+  DBGGUARD;
+
+  if (!objName)
+    {
+      TRACEPOINT;
+      return;
+    }
+
+  gpgrt_lock_lock (&memdbg_log);
+
+  const std::string nameStr (objName);
+
+  auto it = cppObjs.find (nameStr);
+
+  if (it == cppObjs.end())
+    {
+      it = cppObjs.insert (std::make_pair (nameStr, 0)).first;
+    }
+  it->second++;
+
+  gpgrt_lock_unlock (&memdbg_log);
 }
 
 void
 memdbg_dtor (const char *objName)
 {
-  (void)objName;
+  DBGGUARD;
+
+  if (!objName)
+    {
+      TRACEPOINT;
+      return;
+    }
+
+  const std::string nameStr (objName);
+  auto it = cppObjs.find (nameStr);
+
+  if (it == cppObjs.end())
+    {
+      log_error ("%s:%s Dtor of %s before ctor",
+                 SRCNAME, __func__, nameStr.c_str());
+      gpgrt_lock_unlock (&memdbg_log);
+      return;
+    }
+
+  it->second--;
+
+  if (it->second < 0)
+    {
+      log_error ("%s:%s Dtor of %s more often then ctor",
+                 SRCNAME, __func__, nameStr.c_str());
+    }
+  gpgrt_lock_unlock (&memdbg_log);
 
 }
 
 void
 memdbg_dump ()
 {
+  DBGGUARD;
   gpgrt_lock_lock (&memdbg_log);
   log_debug(""
 "------------------------------MEMORY DUMP----------------------------------");

commit e53cbd17a7ea130f4cfac47858a5c1445c0fefb6
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Fri Jul 20 14:55:27 2018 +0200

    Use reffing function as name for IUnknown
    
    * src/memdbg.cpp (_memdbg_addRef, register_name): Use
    calling function as the name for IUnknwon refs.
    
    --
    This is very useful to see at a glance which refs are
    open. E.g. to see the event sink references.

diff --git a/src/memdbg.cpp b/src/memdbg.cpp
index 341e105..4f26fa6 100644
--- a/src/memdbg.cpp
+++ b/src/memdbg.cpp
@@ -44,12 +44,16 @@ GPGRT_LOCK_DEFINE (memdbg_log);
 
 /* Returns true on a name change */
 static bool
-register_name (void *obj)
+register_name (void *obj, const char *nameSuggestion)
 {
 #ifdef HAVE_W32_SYSTEM
 
   char *name = get_object_name ((LPUNKNOWN)obj);
 
+  if (!name && nameSuggestion)
+    {
+      name = strdup (nameSuggestion);
+    }
   if (!name)
     {
       auto it = olNames.find (obj);
@@ -92,7 +96,7 @@ register_name (void *obj)
 }
 
 void
-_memdbg_addRef (void *obj)
+_memdbg_addRef (void *obj, const char *nameSuggestion)
 {
   DBGGUARD;
 
@@ -109,7 +113,7 @@ _memdbg_addRef (void *obj)
     {
       it = olObjs.insert (std::make_pair (obj, 0)).first;
     }
-  if (register_name (obj) && it->second)
+  if (register_name (obj, nameSuggestion) && it->second)
     {
       log_error ("%s:%s Name change without null ref on %p!",
                  SRCNAME, __func__, obj);
diff --git a/src/memdbg.h b/src/memdbg.h
index 37437bd..49e34c1 100644
--- a/src/memdbg.h
+++ b/src/memdbg.h
@@ -35,11 +35,11 @@ extern "C" {
     { \
       log_oom_extra ("%s:%s:%i AddRef on %p", \
                      SRCNAME, __func__, __LINE__, X); \
-      _memdbg_addRef (X); \
+      _memdbg_addRef (X, __func__); \
     } \
 }
 
-void _memdbg_addRef (void *obj);
+void _memdbg_addRef (void *obj, const char *nameSuggestion);
 void memdbg_released (void *obj);
 
 void memdbg_ctor (const char *objName);

commit 52e5891158e99fa532b02d1a13ff17566a7d583a
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Fri Jul 20 14:53:53 2018 +0200

    Add simple dtor / ctor counting of Cpp objs
    
    --
    This adds memdbg trace function to the important objects
    to double check that we don't loose / leak any.

diff --git a/src/attachment.cpp b/src/attachment.cpp
index 68f8025..e626d26 100644
--- a/src/attachment.cpp
+++ b/src/attachment.cpp
@@ -27,10 +27,12 @@
 
 Attachment::Attachment()
 {
+  memdbg_ctor ("Attachment");
 }
 
 Attachment::~Attachment()
 {
+  memdbg_dtor ("Attachment");
   log_debug ("%s:%s", SRCNAME, __func__);
 }
 
diff --git a/src/cryptcontroller.cpp b/src/cryptcontroller.cpp
index 265bc60..d97e891 100644
--- a/src/cryptcontroller.cpp
+++ b/src/cryptcontroller.cpp
@@ -68,6 +68,7 @@ CryptController::CryptController (Mail *mail, bool encrypt, bool sign,
     m_crypto_success (false),
     m_proto (proto)
 {
+  memdbg_ctor ("CryptController");
   log_debug ("%s:%s: CryptController ctor for %p encrypt %i sign %i inline %i.",
              SRCNAME, __func__, mail, encrypt, sign, mail->getDoPGPInline ());
   m_recipient_addrs = vector_to_cArray (mail->getCachedRecipients ());
@@ -75,6 +76,7 @@ CryptController::CryptController (Mail *mail, bool encrypt, bool sign,
 
 CryptController::~CryptController()
 {
+  memdbg_dtor ("CryptController");
   log_debug ("%s:%s:%p",
              SRCNAME, __func__, m_mail);
   release_cArray (m_recipient_addrs);
diff --git a/src/mail.cpp b/src/mail.cpp
index bdb6d7f..a72bc3d 100644
--- a/src/mail.cpp
+++ b/src/mail.cpp
@@ -126,6 +126,7 @@ Mail::Mail (LPDISPATCH mailitem) :
   s_mail_map.insert (std::pair<LPDISPATCH, Mail *> (mailitem, this));
   gpgrt_lock_unlock (&mail_map_lock);
   s_last_mail = this;
+  memdbg_ctor ("Mail");
 }
 
 GPGRT_LOCK_DEFINE(dtor_lock);
@@ -152,6 +153,7 @@ Mail::~Mail()
      that the parser is alive even if the mail is deleted
      while parsing. */
   gpgrt_lock_lock (&dtor_lock);
+  memdbg_dtor ("Mail");
   log_oom_extra ("%s:%s: dtor: Mail: %p item: %p",
                  SRCNAME, __func__, this, m_mailitem);
   std::map<LPDISPATCH, Mail *>::iterator it;
diff --git a/src/mimedataprovider.cpp b/src/mimedataprovider.cpp
index 2899f43..e073b4b 100644
--- a/src/mimedataprovider.cpp
+++ b/src/mimedataprovider.cpp
@@ -489,6 +489,7 @@ MimeDataProvider::MimeDataProvider(bool no_headers) :
   m_has_html_body(false),
   m_collect_everything(no_headers)
 {
+  memdbg_ctor ("MimeDataProvider");
   m_mime_ctx = (mime_context_t) xcalloc (1, sizeof *m_mime_ctx);
   m_mime_ctx->msg = rfc822parse_open (message_cb, this);
   m_mime_ctx->mimestruct_tail = &m_mime_ctx->mimestruct;
@@ -525,6 +526,7 @@ MimeDataProvider::MimeDataProvider(FILE *stream, bool no_headers):
 
 MimeDataProvider::~MimeDataProvider()
 {
+  memdbg_dtor ("MimeDataProvider");
   log_debug ("%s:%s", SRCNAME, __func__);
   while (m_mime_ctx->mimestruct)
     {
diff --git a/src/parsecontroller.cpp b/src/parsecontroller.cpp
index 323b1d3..1b19aba 100644
--- a/src/parsecontroller.cpp
+++ b/src/parsecontroller.cpp
@@ -80,6 +80,7 @@ ParseController::ParseController(LPSTREAM instream, msgtype_t type):
     m_type (type),
     m_block_html (false)
 {
+  memdbg_ctor ("ParseController");
   log_mime_parser ("%s:%s: Creating parser for stream: %p of type %i"
                    " expect no headers: %i expect no mime: %i",
                    SRCNAME, __func__, instream, type,
@@ -94,6 +95,7 @@ ParseController::ParseController(FILE *instream, msgtype_t type):
     m_type (type),
     m_block_html (false)
 {
+  memdbg_ctor ("ParseController");
   log_mime_parser ("%s:%s: Creating parser for stream: %p of type %i",
                    SRCNAME, __func__, instream, type);
 }
@@ -101,6 +103,7 @@ ParseController::ParseController(FILE *instream, msgtype_t type):
 ParseController::~ParseController()
 {
   log_debug ("%s:%s", SRCNAME, __func__);
+  memdbg_dtor ("ParseController");
   delete m_inputprovider;
   delete m_outputprovider;
 }

commit 6bbd203bc201f90b0394af24c105fa187f33ae6f
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Fri Jul 20 14:51:30 2018 +0200

    Accept multipart/mixed application/pgp-encrypted
    
    * src/mapihelp.cpp (change_message_class_ipm_note): Accept
    multipart/mixed with protocol application/pgp-encrypted.
    
    --
    This happens when an encrypted mail is moved by Outlooks
    local filter move rules.
    
    GnuPG-Bug-Id: T4070

diff --git a/src/mapihelp.cpp b/src/mapihelp.cpp
index 04f1be4..afe6d7f 100644
--- a/src/mapihelp.cpp
+++ b/src/mapihelp.cpp
@@ -1048,6 +1048,14 @@ change_message_class_ipm_note (LPMESSAGE message)
              class IPM.Note.  */
           newvalue = xstrdup ("IPM.Note.GpgOL.MultipartSigned");
         }
+      else if (!strcmp (ct, "multipart/mixed")
+               && !strcmp (proto, "application/pgp-encrypted"))
+        {
+          /* This case happens if an encrypted mail is moved
+             by outlook local filter rules.
+          */
+          newvalue = xstrdup ("IPM.Note.GpgOL.MultipartEncrypted");
+        }
       xfree (proto);
     }
   else if (ct && !strcmp (ct, "application/ms-tnef"))

commit ad00070325e7f42380f9adeb27ac2a1a498c3e6a
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Fri Jul 20 14:01:43 2018 +0200

    Remove dead code and add some addRefs
    
    * src/mapihel.cpp, src/mapihelp.h (has_gpgol_body_name)
    (mapi_get_gpgol_body_attachment, mapi_delete_gpgol_body_attachment),
    (mapi_attachment_to_body): Removed.

diff --git a/src/mapihelp.cpp b/src/mapihelp.cpp
index f1beb9d..04f1be4 100644
--- a/src/mapihelp.cpp
+++ b/src/mapihelp.cpp
@@ -837,7 +837,8 @@ is_really_cms_encrypted (LPMESSAGE message)
       goto leave;
     }
   hr = message->OpenAttach (mapirows->aRow[pos].lpProps[0].Value.l,
-                            NULL, MAPI_BEST_ACCESS, &att);	
+                            NULL, MAPI_BEST_ACCESS, &att);
+  memdbg_addRef (att);
   if (FAILED (hr))
     {
       log_error ("%s:%s: can't open attachment %d (%ld): hr=%#lx",
@@ -963,6 +964,7 @@ get_first_attach_mime_tag (LPMESSAGE message)
     }
   hr = message->OpenAttach (mapirows->aRow[pos].lpProps[0].Value.l,
                             NULL, MAPI_BEST_ACCESS, &att);	
+  memdbg_addRef (att);
   if (FAILED (hr))
     {
       log_error ("%s:%s: can't open attachment %d (%ld): hr=%#lx",
@@ -2444,6 +2446,7 @@ mapi_get_attach_as_stream (LPMESSAGE message, mapi_attach_item_t *item,
     return NULL;
 
   hr = message->OpenAttach (item->mapipos, NULL, MAPI_BEST_ACCESS, &att);
+  memdbg_addRef (att);
   if (FAILED (hr))
     {
       log_error ("%s:%s: can't open attachment at %d: hr=%#lx",
@@ -2588,6 +2591,7 @@ mapi_mark_moss_attach (LPMESSAGE message, mapi_attach_item_t *item)
     return -1;
 
   hr = message->OpenAttach (item->mapipos, NULL, MAPI_BEST_ACCESS, &att);
+  memdbg_addRef (att);
   if (FAILED (hr))
     {
       log_error ("%s:%s: can't open attachment at %d: hr=%#lx",
@@ -3177,36 +3181,6 @@ mapi_has_last_decrypted (LPMESSAGE message)
 }
 
 
-/* Helper for mapi_get_gpgol_body_attachment.  */
-static int
-has_gpgol_body_name (LPATTACH obj)
-{
-  HRESULT hr;
-  LPSPropValue propval;
-  int yes = 0;
-
-  hr = HrGetOneProp ((LPMAPIPROP)obj, PR_ATTACH_FILENAME, &propval);
-  if (FAILED(hr))
-    return 0;
-
-  if ( PROP_TYPE (propval->ulPropTag) == PT_UNICODE)
-    {
-      if (!wcscmp (propval->Value.lpszW, L"gpgol000.txt"))
-        yes = 1;
-      else if (!wcscmp (propval->Value.lpszW, L"gpgol000.htm"))
-        yes = 2;
-    }
-  else if ( PROP_TYPE (propval->ulPropTag) == PT_STRING8)
-    {
-      if (!strcmp (propval->Value.lpszA, "gpgol000.txt"))
-        yes = 1;
-      else if (!strcmp (propval->Value.lpszA, "gpgol000.htm"))
-        yes = 2;
-    }
-  MAPIFreeBuffer (propval);
-  return yes;
-}
-
 /* Helper to check whether the file name of OBJ is "smime.p7m".
    Returns on true if so.  */
 static int
@@ -3239,320 +3213,6 @@ has_smime_filename (LPATTACH obj)
 }
 
 
-/* Return the content of the body attachment of MESSAGE.  The body
-   attachment is a hidden attachment created by us for later display.
-   If R_NBYTES is not NULL the number of bytes in the returned buffer
-   is stored there.  If R_ISHTML is not NULL a flag indicating whether
-   the HTML is html formatted is stored there.  If R_PROTECTED is not
-   NULL a flag indicating whether the message was protected is stored
-   there.  If no body attachment can be found or on any other error an
-   error codes is returned and NULL is stored at R_BODY.  Caller must
-   free the returned string.  If NULL is passed for R_BODY, the
-   function will only test whether a body attachment is available and
-   return an error code if not.  R_IS_HTML and R_PROTECTED are not
-   defined in this case.  */
-int
-mapi_get_gpgol_body_attachment (LPMESSAGE message, 
-                                char **r_body, size_t *r_nbytes, 
-                                int *r_ishtml, int *r_protected)
-{    
-  HRESULT hr;
-  SizedSPropTagArray (1L, propAttNum) = { 1L, {PR_ATTACH_NUM} };
-  LPMAPITABLE mapitable;
-  LPSRowSet   mapirows;
-  unsigned int pos, n_attach;
-  ULONG moss_tag;
-  char *body = NULL;
-  int bodytype;
-  int found = 0;
-
-  if (r_body)
-    *r_body = NULL;
-  if (r_ishtml)
-    *r_ishtml = 0;
-  if (r_protected)
-    *r_protected = 0;
-
-  if (get_gpgolattachtype_tag (message, &moss_tag) )
-    return -1;
-
-  hr = message->GetAttachmentTable (0, &mapitable);
-  if (FAILED (hr))
-    {
-      log_debug ("%s:%s: GetAttachmentTable failed: hr=%#lx",
-                 SRCNAME, __func__, hr);
-      return -1;
-    }
-      
-  hr = HrQueryAllRows (mapitable, (LPSPropTagArray)&propAttNum,
-                       NULL, NULL, 0, &mapirows);
-  if (FAILED (hr))
-    {
-      log_debug ("%s:%s: HrQueryAllRows failed: hr=%#lx",
-                 SRCNAME, __func__, hr);
-      gpgol_release (mapitable);
-      return -1;
-    }
-  n_attach = mapirows->cRows > 0? mapirows->cRows : 0;
-  if (!n_attach)
-    {
-      FreeProws (mapirows);
-      gpgol_release (mapitable);
-      log_debug ("%s:%s: No attachments at all", SRCNAME, __func__);
-      return -1;
-    }
-  log_debug ("%s:%s: message has %u attachments\n",
-             SRCNAME, __func__, n_attach);
-
-  for (pos=0; pos < n_attach; pos++) 
-    {
-      LPATTACH att;
-
-      if (mapirows->aRow[pos].cValues < 1)
-        {
-          log_error ("%s:%s: invalid row at pos %d", SRCNAME, __func__, pos);
-          continue;
-        }
-      if (mapirows->aRow[pos].lpProps[0].ulPropTag != PR_ATTACH_NUM)
-        {
-          log_error ("%s:%s: invalid prop at pos %d", SRCNAME, __func__, pos);
-          continue;
-        }
-      hr = message->OpenAttach (mapirows->aRow[pos].lpProps[0].Value.l,
-                                NULL, MAPI_BEST_ACCESS, &att);	
-      if (FAILED (hr))
-        {
-          log_error ("%s:%s: can't open attachment %d (%ld): hr=%#lx",
-                     SRCNAME, __func__, pos, 
-                     mapirows->aRow[pos].lpProps[0].Value.l, hr);
-          continue;
-        }
-      if ((bodytype=has_gpgol_body_name (att))
-           && get_gpgolattachtype (att, moss_tag) == ATTACHTYPE_FROMMOSS)
-        {
-          found = 1;
-          if (!r_body)
-            ; /* Body content has not been requested. */
-          else
-            {
-              char *charset;
-              
-              if (get_attach_method (att) == ATTACH_BY_VALUE)
-                body = attach_to_buffer (att, r_nbytes);
-              if (body && (charset = mapi_get_gpgol_charset ((LPMESSAGE)att)))
-                {
-                  /* We only support transcoding from Latin-1 for now.  */
-                  if (strcmp (charset, "iso-8859-1") 
-                      && !strcmp (charset, "latin-1"))
-                    log_debug ("%s:%s: Using Latin-1 instead of %s",
-                               SRCNAME, __func__, charset);
-                  xfree (charset);
-                  charset = latin1_to_utf8 (body);
-                  xfree (body);
-                  body = charset;
-                }
-            }
-          gpgol_release (att);
-          if (r_ishtml)
-            *r_ishtml = (bodytype == 2);
-          break;
-        }
-      gpgol_release (att);
-    }
-  FreeProws (mapirows);
-  gpgol_release (mapitable);
-  if (!found)
-    {
-      log_error ("%s:%s: no suitable body attachment found", SRCNAME,__func__);
-      if (r_body)
-        *r_body = native_to_utf8 
-          (_("[The content of this message is not visible"
-             " due to an processing error in GpgOL.]"));
-      return -1;
-    }
-
-  if (r_body)
-    *r_body = body;
-  else
-    xfree (body);  /* (Should not happen.)  */
-  return 0;
-}
-
-
-/* Delete a possible body atatchment.  Returns true if an atatchment
-   has been deleted.  */
-int
-mapi_delete_gpgol_body_attachment (LPMESSAGE message)
-{    
-  HRESULT hr;
-  SizedSPropTagArray (1L, propAttNum) = { 1L, {PR_ATTACH_NUM} };
-  LPMAPITABLE mapitable;
-  LPSRowSet   mapirows;
-  unsigned int pos, n_attach;
-  ULONG moss_tag;
-  int found = 0;
-
-  if (get_gpgolattachtype_tag (message, &moss_tag) )
-    return 0;
-
-  hr = message->GetAttachmentTable (0, &mapitable);
-  if (FAILED (hr))
-    {
-      log_debug ("%s:%s: GetAttachmentTable failed: hr=%#lx",
-                 SRCNAME, __func__, hr);
-      return 0;
-    }
-      
-  hr = HrQueryAllRows (mapitable, (LPSPropTagArray)&propAttNum,
-                       NULL, NULL, 0, &mapirows);
-  if (FAILED (hr))
-    {
-      log_debug ("%s:%s: HrQueryAllRows failed: hr=%#lx",
-                 SRCNAME, __func__, hr);
-      gpgol_release (mapitable);
-      return 0;
-    }
-  n_attach = mapirows->cRows > 0? mapirows->cRows : 0;
-  if (!n_attach)
-    {
-      FreeProws (mapirows);
-      gpgol_release (mapitable);
-      return 0; /* No Attachments.  */
-    }
-
-  for (pos=0; pos < n_attach; pos++) 
-    {
-      LPATTACH att;
-
-      if (mapirows->aRow[pos].cValues < 1)
-        {
-          log_error ("%s:%s: invalid row at pos %d", SRCNAME, __func__, pos);
-          continue;
-        }
-      if (mapirows->aRow[pos].lpProps[0].ulPropTag != PR_ATTACH_NUM)
-        {
-          log_error ("%s:%s: invalid prop at pos %d", SRCNAME, __func__, pos);
-          continue;
-        }
-      hr = message->OpenAttach (mapirows->aRow[pos].lpProps[0].Value.l,
-                                NULL, MAPI_BEST_ACCESS, &att);	
-      if (FAILED (hr))
-        {
-          log_error ("%s:%s: can't open attachment %d (%ld): hr=%#lx",
-                     SRCNAME, __func__, pos, 
-                     mapirows->aRow[pos].lpProps[0].Value.l, hr);
-          continue;
-        }
-      if (has_gpgol_body_name (att)
-          && get_gpgolattachtype (att, moss_tag) == ATTACHTYPE_FROMMOSS)
-        {
-          gpgol_release (att);
-          hr = message->DeleteAttach (mapirows->aRow[pos].lpProps[0].Value.l,
-                                      0, NULL, 0);
-          if (hr)
-            log_error ("%s:%s: DeleteAttach failed: hr=%#lx\n",
-                         SRCNAME, __func__, hr); 
-          else
-            {
-              log_debug ("%s:%s: body attachment deleted\n", 
-                         SRCNAME, __func__); 
-              found = 1;
-              
-            }
-          break;
-        }
-      gpgol_release (att);
-    }
-  FreeProws (mapirows);
-  gpgol_release (mapitable);
-  return found;
-}
-
-
-/* Copy the attachment ITEM of the message MESSAGE verbatim to the
-   PR_BODY property.  Returns 0 on success.  This function does not
-   call SaveChanges. */
-int
-mapi_attachment_to_body (LPMESSAGE message, mapi_attach_item_t *item)
-{
-  int result = -1;
-  HRESULT hr; 
-  LPATTACH att = NULL;
-  LPSTREAM instream = NULL;
-  LPSTREAM outstream = NULL;
-  LPUNKNOWN punk;
-
-  if (!message || !item || item->end_of_table || item->mapipos == -1)
-    return -1; /* Error.  */
-
-  hr = message->OpenAttach (item->mapipos, NULL, MAPI_BEST_ACCESS, &att);
-  if (FAILED (hr))
-    {
-      log_error ("%s:%s: can't open attachment at %d: hr=%#lx",
-                 SRCNAME, __func__, item->mapipos, hr);
-      goto leave;
-    }
-  if (item->method != ATTACH_BY_VALUE)
-    {
-      log_error ("%s:%s: attachment: method not supported", SRCNAME, __func__);
-      goto leave;
-    }
-
-  hr = gpgol_openProperty (att, PR_ATTACH_DATA_BIN, &IID_IStream,
-                          0, 0, (LPUNKNOWN*) &instream);
-  if (FAILED (hr))
-    {
-      log_error ("%s:%s: can't open data stream of attachment: hr=%#lx",
-                 SRCNAME, __func__, hr);
-      goto leave;
-    }
-
-
-  punk = (LPUNKNOWN)outstream;
-  hr = gpgol_openProperty (message, PR_BODY_A, &IID_IStream, 0,
-                              MAPI_CREATE|MAPI_MODIFY, &punk);
-  if (FAILED (hr))
-    {
-      log_error ("%s:%s: can't open body stream for update: hr=%#lx",
-                 SRCNAME, __func__, hr);
-      goto leave;
-    }
-  outstream = (LPSTREAM)punk;
-
-  {
-    ULARGE_INTEGER cb;
-    cb.QuadPart = 0xffffffffffffffffll;
-    hr = instream->CopyTo (outstream, cb, NULL, NULL);
-  }
-  if (hr)
-    {
-      log_error ("%s:%s: can't copy streams: hr=%#lx\n",
-                 SRCNAME, __func__, hr); 
-      goto leave;
-    }
-  hr = outstream->Commit (0);
-  if (hr)
-    {
-      log_error ("%s:%s: commiting output stream failed: hr=%#lx",
-                 SRCNAME, __func__, hr);
-      goto leave;
-    }
-  result = 0;
-  
- leave:
-  if (outstream)
-    {
-      if (result)
-        outstream->Revert ();
-      gpgol_release (outstream);
-    }
-  if (instream)
-    gpgol_release (instream);
-  if (att)
-    gpgol_release (att);
-  return result;
-}
-
 /* Copy the MAPI body to a PGPBODY type attachment. */
 int
 mapi_body_to_attachment (LPMESSAGE message)
diff --git a/src/mapihelp.h b/src/mapihelp.h
index ede2cbf..4fc34d2 100644
--- a/src/mapihelp.h
+++ b/src/mapihelp.h
@@ -106,13 +106,6 @@ char *mapi_get_message_content_type (LPMESSAGE message,
                                      char **r_protocol, char **r_smtype);
 
 int   mapi_has_last_decrypted (LPMESSAGE message);
-int   mapi_get_gpgol_body_attachment (LPMESSAGE message,
-                                      char **r_body, size_t *r_nbytes,
-                                      int *r_ishtml, int *r_protected);
-
-int   mapi_delete_gpgol_body_attachment (LPMESSAGE message);
-
-int   mapi_attachment_to_body (LPMESSAGE message, mapi_attach_item_t *item);
 
 attachtype_t get_gpgolattachtype (LPATTACH obj, ULONG tag);
 

commit aea2712f472a25c1a85906bcb0400ef3779771dd
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Fri Jul 20 13:15:49 2018 +0200

    Fix ref leak on no object error
    
    * src/oomhelp.cpp (get_oom_object): Release pDisp always.
    
    --
    This fixes a common reference leak from the check_inline_response
    codepath. Where it would leak for everything that is not an
    inline response.

diff --git a/src/oomhelp.cpp b/src/oomhelp.cpp
index 462d44e..1a11560 100644
--- a/src/oomhelp.cpp
+++ b/src/oomhelp.cpp
@@ -362,6 +362,7 @@ get_oom_object (LPDISPATCH pStart, const char *fullname)
       pObj = vtResult.pdispVal;
       memdbg_addRef (pObj);
     }
+  gpgol_release (pDisp);
   log_debug ("%s:%s: no object", SRCNAME, __func__);
   return NULL;
 }

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

Summary of changes:
 src/attachment.cpp       |   2 +
 src/cryptcontroller.cpp  |   2 +
 src/gpgoladdin.cpp       |   5 +
 src/gpgoladdin.h         |   1 +
 src/mail.cpp             |   6 +
 src/mapihelp.cpp         | 358 ++---------------------------------------------
 src/mapihelp.h           |   7 -
 src/memdbg.cpp           |  61 +++++++-
 src/memdbg.h             |   4 +-
 src/mimedataprovider.cpp |   2 +
 src/oomhelp.cpp          |   1 +
 src/parsecontroller.cpp  |   3 +
 12 files changed, 93 insertions(+), 359 deletions(-)


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




More information about the Gnupg-commits mailing list