[git] GpgOL - branch, nomapi, updated. gpgol-1.4.0-43-g03353e6

by Andre Heinecke cvs at cvs.gnupg.org
Thu Sep 15 16:56:33 CEST 2016


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, nomapi has been updated
       via  03353e62d35b54051198f1ef2f076c2fdbdf3136 (commit)
       via  0059fed320744657ab758b6b87b53c2121f6ec6c (commit)
       via  66ff2a0a37f61da5561a12926ea4846025c00686 (commit)
       via  1c75086691a62c79c95a142acf61cd84724876c7 (commit)
      from  487288bf5fe607949913a90d582bc9407d25a0f1 (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 03353e62d35b54051198f1ef2f076c2fdbdf3136
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Thu Sep 15 16:55:46 2016 +0200

    Fix shared ptr leak in freed ctx
    
    * src/mimedataprovider.cpp (~MimeDataProvider): Set attachment
    to NULL to unref the shared pointer.

diff --git a/src/mimedataprovider.cpp b/src/mimedataprovider.cpp
index efdab94..bf84b7a 100644
--- a/src/mimedataprovider.cpp
+++ b/src/mimedataprovider.cpp
@@ -529,6 +529,7 @@ MimeDataProvider::~MimeDataProvider()
       m_mime_ctx->mimestruct = tmp;
     }
   rfc822parse_close (m_mime_ctx->msg);
+  m_mime_ctx->current_attachment = NULL;
   xfree (m_mime_ctx);
   if (m_signature)
     {

commit 0059fed320744657ab758b6b87b53c2121f6ec6c
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Thu Sep 15 16:51:30 2016 +0200

    Fix memory leaks in mimedataprovider
    
    * src/mimedataprovider.cpp (~MimeDataProvider): Fix memory leaks.

diff --git a/src/mimedataprovider.cpp b/src/mimedataprovider.cpp
index 46e4687..efdab94 100644
--- a/src/mimedataprovider.cpp
+++ b/src/mimedataprovider.cpp
@@ -520,7 +520,16 @@ MimeDataProvider::MimeDataProvider(FILE *stream):
 MimeDataProvider::~MimeDataProvider()
 {
   log_debug ("%s:%s", SRCNAME, __func__);
-  free (m_mime_ctx);
+  while (m_mime_ctx->mimestruct)
+    {
+      mimestruct_item_t tmp = m_mime_ctx->mimestruct->next;
+      xfree (m_mime_ctx->mimestruct->filename);
+      xfree (m_mime_ctx->mimestruct->charset);
+      xfree (m_mime_ctx->mimestruct);
+      m_mime_ctx->mimestruct = tmp;
+    }
+  rfc822parse_close (m_mime_ctx->msg);
+  xfree (m_mime_ctx);
   if (m_signature)
     {
       delete m_signature;

commit 66ff2a0a37f61da5561a12926ea4846025c00686
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Thu Sep 15 15:37:24 2016 +0200

    Add simple test for multipart/encrypted
    
    * tests/data/openpgp-encrypted.mbox: New.
    * tests/data/openpgp-encrypted.plain: New.
    * tests/t-parser.cpp: Add test.

diff --git a/tests/data/openpgp-encrypted.mbox b/tests/data/openpgp-encrypted.mbox
new file mode 100644
index 0000000..5102fa7
--- /dev/null
+++ b/tests/data/openpgp-encrypted.mbox
@@ -0,0 +1,36 @@
+From test at kolab.org Wed, 08 Sep 2010 17:02:52 +0200
+From: OpenPGP Test <test at kolab.org>
+To: test at kolab.org
+Subject: OpenPGP encrypted
+Date: Wed, 08 Sep 2010 17:02:52 +0200
+User-Agent: KMail/4.6 pre (Linux/2.6.34-rc2-2-default; KDE/4.5.60; x86_64; ; )
+MIME-Version: 1.0
+Content-Type: multipart/encrypted; boundary="nextPart1357031.ppLHckZtsp"; protocol="application/pgp-encrypted"
+Content-Transfer-Encoding: 7Bit
+
+
+--nextPart1357031.ppLHckZtsp
+Content-Type: application/pgp-encrypted
+Content-Disposition: attachment
+
+Version: 1
+--nextPart1357031.ppLHckZtsp
+Content-Type: application/octet-stream
+Content-Disposition: inline; filename="msg.asc"
+
+-----BEGIN PGP MESSAGE-----
+Version: GnuPG v2.0.15 (GNU/Linux)
+
+hQEMAwzOQ1qnzNo7AQgAtWfDWWI2JUGuptpackiIxpWViEEpGAeruETubiIPwxNb
+DNmXrMDhbm/zIbPntIGWJDgUMfABZCUgmlJLWhsceDTt+tXnWGha2VYrN2/WsF6/
+Pqs/TavTvMIJQHDaIH5yDDCaMoq/mGSbcu7go2H8Sw7aBEYlM8jGlqc1HziXnZ1q
+3vDiA+4qWfvbNoSRo1kb9Pcq997yg6WqZXH2hJ7cp+hIQ4uTP1/+qgYHMvfPlzQk
+XcDguGbIer88ELhuR5622unGBAB4dqp+5w6n9c6rrCH81qhV4W0nqSEvj1tBj78S
+ZTi6VBAo5eS0e3iOJqMpwUZz6hQUpJw2wnNRGvLgI9KZAag0HkgPdMeANowg7vpE
+L4nU7B0ybhswA2Y7QT/wwCDZu9N1JGeBmy0dgy4sA38Ki27rn2/lIaP0j14JycwM
+RTJ1uwI+ZuQiwXlyYtdFZJWe8nraWARch0oKqhaR7aSsxGWo63eiGEQhkQCBFBb3
+Vg0nNCZRBauEqIESEW5EV2zrJqdfNYcz+f9IP125dnQEKgLZ6FxTt3+v
+=mhNl
+-----END PGP MESSAGE-----
+
+--nextPart1357031.ppLHckZtsp--
diff --git a/tests/data/openpgp-encrypted.plain b/tests/data/openpgp-encrypted.plain
new file mode 100644
index 0000000..7faf7d0
--- /dev/null
+++ b/tests/data/openpgp-encrypted.plain
@@ -0,0 +1 @@
+encrypted message text
\ No newline at end of file
diff --git a/tests/t-parser.cpp b/tests/t-parser.cpp
index fdef25a..bd41395 100644
--- a/tests/t-parser.cpp
+++ b/tests/t-parser.cpp
@@ -38,6 +38,12 @@ struct
     NULL,
     NULL,
     0 },
+  { DATADIR "/openpgp-encrypted.mbox",
+    MSGTYPE_GPGOL_MULTIPART_ENCRYPTED,
+    DATADIR "/openpgp-encrypted.plain",
+    NULL,
+    NULL,
+    0 },
   { NULL, MSGTYPE_UNKNOWN, NULL, NULL, 0 }
 };
 

commit 1c75086691a62c79c95a142acf61cd84724876c7
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Thu Sep 15 15:35:35 2016 +0200

    Handle multipart/encrypted pgp mails
    
    * src/mimedataprovider.cpp (mime_context): Add field for is_encrypted.
    * src/parsecontroller.cpp (parse): Reset input stream.
    
    --
    Now that we mix the handler for ciphertext and plaintext we need
    to check if we are on encrypted data when collecting. Also
    we don't save the body in an attachment anymore.

diff --git a/src/mimedataprovider.cpp b/src/mimedataprovider.cpp
index d75bd51..46e4687 100644
--- a/src/mimedataprovider.cpp
+++ b/src/mimedataprovider.cpp
@@ -72,8 +72,9 @@ struct mime_context
                                                      attachment */
   int collect_body;       /* True if we are collcting the body */
   int collect_html_body;  /* True if we are collcting the html body */
-  int collect_signeddata; /* True if we are collecting the signed data. */
+  int collect_crypto_data; /* True if we are collecting the signed data. */
   int collect_signature;  /* True if we are collecting a signature.  */
+  int is_encrypted;       /* True if we are working on an encrypted mail. */
   int start_hashing;      /* Flag used to start collecting signed data. */
   int hashing_level;      /* MIME level where we started hashing. */
   int is_qp_encoded;      /* Current part is QP encoded. */
@@ -274,6 +275,14 @@ t2body (MimeDataProvider *provider, rfc822parse_t msg)
           /* Need to start the hashing after the next boundary. */
           ctx->start_hashing = 1;
         }
+      else if (!strcmp (ctsub, "encrypted") &&
+               (s = rfc822parse_query_parameter (field, "protocol", 0)))
+        {
+           if (!strcmp (s, "application/pgp-encrypted"))
+             ctx->protocol = PROTOCOL_OPENPGP;
+           /* We expect an encrypted mime part. */
+           ctx->is_encrypted = 1;
+        }
     }
   else if (!strcmp (ctmain, "text"))
     {
@@ -295,6 +304,14 @@ t2body (MimeDataProvider *provider, rfc822parse_t msg)
       ctx->collect_signature = 1;
       log_mime_parser ("Collecting signature now");
     }
+  else if (ctx->nesting_level == 1 && ctx->is_encrypted
+           && !strcmp (ctmain, "application")
+           && (ctx->protocol == PROTOCOL_OPENPGP
+               && !strcmp (ctsub, "octet-stream")))
+    {
+      log_mime_parser ("Collecting encrypted data from now on");
+      ctx->collect_crypto_data = 1;
+    }
   else /* Other type. */
     {
       /* Check whether this attachment is an opaque signed S/MIME
@@ -413,7 +430,7 @@ message_cb (void *opaque, rfc822parse_event_t event,
         {
           ctx->start_hashing = 2;
           ctx->hashing_level = ctx->nesting_level;
-          ctx->collect_signeddata = 1;
+          ctx->collect_crypto_data = 1;
         }
     }
 
@@ -449,7 +466,7 @@ message_cb (void *opaque, rfc822parse_event_t event,
       if (ctx->start_hashing == 2 && ctx->hashing_level == ctx->nesting_level)
         {
           ctx->start_hashing = 3; /* Avoid triggering it again. */
-          ctx->collect_signeddata = 0;
+          ctx->collect_crypto_data = 0;
         }
       break;
 
@@ -582,21 +599,22 @@ MimeDataProvider::collect_input_lines(const char *input, size_t insize)
 
           /* If we are currently in a collecting state actually
              collect that line */
-          if (m_mime_ctx->collect_signeddata)
+          if (m_mime_ctx->collect_crypto_data && m_mime_ctx->start_hashing)
             {
               /* Save the signed data.  Note that we need to delay
                  the CR/LF because the last line ending belongs to the
                  next boundary. */
-              if (m_mime_ctx->collect_signeddata == 2)
+              if (m_mime_ctx->collect_crypto_data == 2)
                 {
                   m_crypto_data.write ("\r\n", 2);
                 }
-              log_debug ("Writing signeddata: %s pos: " SIZE_T_FORMAT,
-                         linebuf, pos);
+              log_mime_parser ("Writing raw crypto data: %.*s",
+                               (int)pos, linebuf);
               m_crypto_data.write (linebuf, pos);
-              m_mime_ctx->collect_signeddata = 2;
+              m_mime_ctx->collect_crypto_data = 2;
             }
-          if (m_mime_ctx->in_data && m_mime_ctx->collect_attachment)
+          if (m_mime_ctx->in_data && m_mime_ctx->collect_attachment
+              && !m_mime_ctx->collect_crypto_data)
             {
               /* We are inside of an attachment part.  Write it out. */
               if (m_mime_ctx->collect_attachment == 1)  /* Skip the first line. */
@@ -612,19 +630,27 @@ MimeDataProvider::collect_input_lines(const char *input, size_t insize)
 
               if (m_mime_ctx->collect_body)
                 {
-                  m_body += std::string(linebuf, len);
-                  if (!m_mime_ctx->is_base64_encoded && !slbrk)
+                  if (m_mime_ctx->collect_body == 2)
                     {
-                      m_body += "\r\n";
+                      m_body += std::string(linebuf, len);
+                      if (!m_mime_ctx->is_base64_encoded && !slbrk)
+                        {
+                          m_body += "\r\n";
+                        }
                     }
+                  m_mime_ctx->collect_body = 2;
                 }
               else if (m_mime_ctx->collect_html_body)
                 {
-                  m_html_body += std::string(linebuf, len);
-                  if (!m_mime_ctx->is_base64_encoded && !slbrk)
+                  if (m_mime_ctx->collect_html_body == 2)
                     {
-                      m_body += "\r\n";
+                      m_html_body += std::string(linebuf, len);
+                      if (!m_mime_ctx->is_base64_encoded && !slbrk)
+                        {
+                          m_body += "\r\n";
+                        }
                     }
+                  m_mime_ctx->collect_html_body = 2;
                 }
               else if (m_mime_ctx->current_attachment && len)
                 {
@@ -677,6 +703,8 @@ MimeDataProvider::collect_input_lines(const char *input, size_t insize)
                 len = b64_decode (&m_mime_ctx->base64, linebuf, pos);
               else
                 len = pos;
+              log_debug ("Writing crypto data: %.*s",
+                         (int)pos, linebuf);
               if (len)
                 m_crypto_data.write(linebuf, len);
               if (!m_mime_ctx->is_base64_encoded && !slbrk)
diff --git a/src/parsecontroller.cpp b/src/parsecontroller.cpp
index e9c61a5..1ee6ad1 100644
--- a/src/parsecontroller.cpp
+++ b/src/parsecontroller.cpp
@@ -132,6 +132,7 @@ ParseController::parse()
              protocol == CMS ? "CMS" : "Unknown");
   if (decrypt)
     {
+      input.seek (0, SEEK_SET);
       auto combined_result = ctx->decryptAndVerify(input, output);
       m_decrypt_result = combined_result.first;
       m_verify_result = combined_result.second;

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

Summary of changes:
 src/mimedataprovider.cpp           | 70 +++++++++++++++++++++++++++++---------
 src/parsecontroller.cpp            |  1 +
 tests/data/openpgp-encrypted.mbox  | 36 ++++++++++++++++++++
 tests/data/openpgp-encrypted.plain |  1 +
 tests/t-parser.cpp                 |  6 ++++
 5 files changed, 98 insertions(+), 16 deletions(-)
 create mode 100644 tests/data/openpgp-encrypted.mbox
 create mode 100644 tests/data/openpgp-encrypted.plain


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




More information about the Gnupg-commits mailing list