[git] GpgOL - branch, master, updated. gpgol-2.0.6-121-g1441f67

by Andre Heinecke cvs at cvs.gnupg.org
Thu Apr 5 14:06:30 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  1441f6710db976c76b5cb64073be05b318df84ce (commit)
       via  21893fa30aec87dc3ec25153490c41e00f1641b0 (commit)
      from  c9343fa680d37927341292c48ef3be2001e1a6cc (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 1441f6710db976c76b5cb64073be05b318df84ce
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Thu Apr 5 14:05:13 2018 +0200

    Fix encrypt to self if keycache is used
    
    * src/cryptcontroller.cpp (CryptController::resolve_keys_cached):
    Add sender to recipients if encrypt is selected.
    * src/keycache.cpp, src/keycache.h (KeyCache::getEncryptionKeys):
    Use a vector of strings instead of carray.
    
    --
    Oooops.

diff --git a/src/cryptcontroller.cpp b/src/cryptcontroller.cpp
index eddc9f7..1065f6e 100644
--- a/src/cryptcontroller.cpp
+++ b/src/cryptcontroller.cpp
@@ -309,12 +309,16 @@ CryptController::resolve_keys_cached()
 
   if (m_encrypt)
     {
-      m_recipients = cache->getEncryptionKeys((const char **)m_recipient_addrs, GpgME::OpenPGP);
+      const auto cached_sender = m_mail->get_cached_sender ();
+      auto recps = cArray_to_vector ((const char**) m_recipient_addrs);
+      recps.push_back (cached_sender);
+
+      m_recipients = cache->getEncryptionKeys(recps, GpgME::OpenPGP);
       m_proto = GpgME::OpenPGP;
 
       if (m_recipients.empty() && opt.enable_smime)
         {
-          m_recipients = cache->getEncryptionKeys((const char **)m_recipient_addrs, GpgME::CMS);
+          m_recipients = cache->getEncryptionKeys(recps, GpgME::CMS);
           fallbackToSMIME = true;
           m_proto = GpgME::CMS;
         }
diff --git a/src/keycache.cpp b/src/keycache.cpp
index 73011aa..29382d5 100644
--- a/src/keycache.cpp
+++ b/src/keycache.cpp
@@ -219,22 +219,22 @@ public:
     return key;
   }
 
-  std::vector<GpgME::Key> getEncryptionKeys (const char **recipients,
+  std::vector<GpgME::Key> getEncryptionKeys (const std::vector<std::string> &recipients,
                                              GpgME::Protocol proto)
   {
     std::vector<GpgME::Key> ret;
-    if (!recipients)
+    if (recipients.empty ())
       {
         TRACEPOINT;
         return ret;
       }
-    for (int i = 0; recipients[i]; i++)
+    for (const auto &recip: recipients)
       {
-        const auto key = getKey (recipients[i], proto);
+        const auto key = getKey (recip.c_str (), proto);
         if (key.isNull())
           {
             log_mime_parser ("%s:%s: No key for %s. no internal encryption",
-                       SRCNAME, __func__, recipients[i]);
+                       SRCNAME, __func__, recip.c_str ());
             return std::vector<GpgME::Key>();
           }
 
@@ -242,20 +242,20 @@ public:
             key.isExpired() || key.isDisabled() || key.isInvalid())
           {
             log_mime_parser ("%s:%s: Invalid key for %s. no internal encryption",
-                       SRCNAME, __func__, recipients[i]);
+                       SRCNAME, __func__, recip.c_str ());
             return std::vector<GpgME::Key>();
           }
 
         if (in_de_vs_mode () && key.isDeVs ())
           {
             log_mime_parser ("%s:%s: key for %s is not deVS",
-                       SRCNAME, __func__, recipients[i]);
+                       SRCNAME, __func__, recip.c_str ());
             return std::vector<GpgME::Key>();
           }
 
         bool validEnough = false;
         /* Here we do the check if the key is valid for this recipient */
-        const auto addrSpec = GpgME::UserID::addrSpecFromString (recipients[i]);
+        const auto addrSpec = GpgME::UserID::addrSpecFromString (recip.c_str ());
         for (const auto &uid: key.userIDs ())
           {
             if (addrSpec != uid.addrSpec())
@@ -272,7 +272,7 @@ public:
         if (!validEnough)
           {
             log_mime_parser ("%s:%s: UID for %s does not have at least marginal trust",
-                             SRCNAME, __func__, recipients[i]);
+                             SRCNAME, __func__, recip.c_str ());
             return std::vector<GpgME::Key>();
           }
         // Accepting key
@@ -309,7 +309,7 @@ KeyCache::getSigningKey (const char *addr, GpgME::Protocol proto) const
 }
 
 std::vector<GpgME::Key>
-KeyCache::getEncryptionKeys (const char **recipients, GpgME::Protocol proto) const
+KeyCache::getEncryptionKeys (const std::vector<std::string> &recipients, GpgME::Protocol proto) const
 {
   return d->getEncryptionKeys (recipients, proto);
 }
diff --git a/src/keycache.h b/src/keycache.h
index 9a3aded..41e7255 100644
--- a/src/keycache.h
+++ b/src/keycache.h
@@ -53,7 +53,7 @@ public:
        are taken from the internal cache. If
        one recipient can't be resolved an empty
        list is returned. */
-    std::vector<GpgME::Key> getEncryptionKeys (const char **recipients,
+    std::vector<GpgME::Key> getEncryptionKeys (const std::vector<std::string> &recipients,
                                                GpgME::Protocol proto) const;
 
     /* Start a key location in a background thread filling

commit 21893fa30aec87dc3ec25153490c41e00f1641b0
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Thu Apr 5 14:04:38 2018 +0200

    Add helper to convert carray to vector
    
    * src/cpphelp.cpp, src/cpphelp.h (cArray_to_vector): New.

diff --git a/src/cpphelp.cpp b/src/cpphelp.cpp
index 122703e..c09b16d 100644
--- a/src/cpphelp.cpp
+++ b/src/cpphelp.cpp
@@ -82,6 +82,23 @@ vector_to_cArray(const std::vector<std::string> &vec)
   return ret;
 }
 
+std::vector <std::string>
+cArray_to_vector(const char **cArray)
+{
+  std::vector<std::string> ret;
+
+  if (!cArray)
+    {
+      return ret;
+    }
+
+  for (int i = 0; cArray[i]; i++)
+    {
+      ret.push_back (std::string (cArray[i]));
+    }
+  return ret;
+}
+
 bool
 in_de_vs_mode()
 {
diff --git a/src/cpphelp.h b/src/cpphelp.h
index c2f2983..953f861 100644
--- a/src/cpphelp.h
+++ b/src/cpphelp.h
@@ -38,6 +38,7 @@ void trim (std::string &s);
 
 /* Convert a string vector to a null terminated char array */
 char **vector_to_cArray (const std::vector<std::string> &vec);
+std::vector <std::string> cArray_to_vector (const char **cArray);
 
 /* Check if we are in de_vs mode. */
 bool in_de_vs_mode ();

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

Summary of changes:
 src/cpphelp.cpp         | 17 +++++++++++++++++
 src/cpphelp.h           |  1 +
 src/cryptcontroller.cpp |  8 ++++++--
 src/keycache.cpp        | 20 ++++++++++----------
 src/keycache.h          |  2 +-
 5 files changed, 35 insertions(+), 13 deletions(-)


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




More information about the Gnupg-commits mailing list