[git] GpgEX - branch, master, updated. gpgex-1.0.4-7-g8c3c8db

by Andre Heinecke cvs at cvs.gnupg.org
Sun May 14 13:44:36 CEST 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 the Windows Explorer".

The branch, master has been updated
       via  8c3c8dbd7b5c3b527e1af459ba608f5cdb06d8a1 (commit)
       via  cb6f5468a6d31cbef6898c5d237d8c2188c347b1 (commit)
      from  cb5f44e8c5d947aa85a345fa9446cd4920b626f7 (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 8c3c8dbd7b5c3b527e1af459ba608f5cdb06d8a1
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Sun May 14 13:42:42 2017 +0200

    Use c++ hardening flags
    
    * configure.ac (CXXFLAGS, CFLAGS): Add hardening flags.
    
    --
    Especially DEP / ASLR is important for windows as one plugin
    affects an otherwise DEP / ASLR enabled process. This also
    avoids that we can't run on systems where policies only allow
    binaries with these flags.
    
    GnuPG-Bug-ID: T2366

diff --git a/configure.ac b/configure.ac
index de2f494..baef053 100644
--- a/configure.ac
+++ b/configure.ac
@@ -204,6 +204,9 @@ if test "$GCC" = yes; then
         CXXFLAGS="$CXXFLAGS -Wcast-align -Wshadow"
         CXXFLAGS="$CXXFLAGS -Wno-format-y2k -Wformat-security"
     fi
+    HARDENING="-Wl,--dynamicbase -Wl,--nxcompat -fno-exceptions -D_FORTIFY_SOURCE=2 -O0"
+    CFLAGS="$CFLAGS $HARDENING"
+    CXXFLAGS="$CXXFLAGS $HARDENING"
 fi
 
 AC_SUBST(W32LIBS)

commit cb6f5468a6d31cbef6898c5d237d8c2188c347b1
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Sun May 14 13:40:37 2017 +0200

    Fix build without exceptions
    
    * src/client.cc (escape): Return empty string instead of exception
    if percent_escape fails.
    (call_assuan_async): Handle errors instead of throwing / catching.
    * src/gpgex.cc (gpgex_t::Initialize): Handle errors instead of
    throwing / catching.
    
    --
    Exceptions are evil and just asking for trouble. Especially native
    C++ Exceptions on Windows _and_ combined with MinGW.

diff --git a/src/client.cc b/src/client.cc
index ccfa0ac..a9ce5f0 100644
--- a/src/client.cc
+++ b/src/client.cc
@@ -256,7 +256,7 @@ escape (string str)
   char *arg_esc = percent_escape (str.c_str (), "+= ");
 
   if (arg_esc == NULL)
-    throw std::bad_alloc ();
+    return std::string();
 
   string res = arg_esc;
   free (arg_esc);
@@ -439,36 +439,25 @@ call_assuan_async (LPVOID arg)
       goto leave;
     }
 
-  try
-    {
-      /* Set the input files.  We don't specify the output files.  */
-      for (unsigned int i = 0; i < filenames.size (); i++)
-        {
-          msg = "FILE " + escape (filenames[i]);
-
-          (void) TRACE_LOG1 ("sending cmd: %s", msg.c_str ());
-
-          rc = assuan_transact (ctx, msg.c_str (),
-                                NULL, NULL, NULL, NULL, NULL, NULL);
-          if (rc)
-            goto leave;
-        }
-
-      /* Set the --nohup option, so that the operation continues and
-         completes in the background.  */
-      msg = ((string) cmd) + " --nohup";
-      (void) TRACE_LOG1 ("sending cmd: %s", msg.c_str ());
-      rc = assuan_transact (ctx, msg.c_str (),
-                            NULL, NULL, NULL, NULL, NULL, NULL);
-    }
-  catch (std::bad_alloc)
-    {
-      rc = gpg_error (GPG_ERR_ENOMEM);
-    }
-  catch (...)
-    {
-      rc = gpg_error (GPG_ERR_GENERAL);
-    }
+    /* Set the input files.  We don't specify the output files.  */
+    for (unsigned int i = 0; i < filenames.size (); i++)
+      {
+        msg = "FILE " + escape (filenames[i]);
+
+        (void) TRACE_LOG1 ("sending cmd: %s", msg.c_str ());
+
+        rc = assuan_transact (ctx, msg.c_str (),
+                              NULL, NULL, NULL, NULL, NULL, NULL);
+        if (rc)
+          goto leave;
+      }
+
+    /* Set the --nohup option, so that the operation continues and
+       completes in the background.  */
+    msg = ((string) cmd) + " --nohup";
+    (void) TRACE_LOG1 ("sending cmd: %s", msg.c_str ());
+    rc = assuan_transact (ctx, msg.c_str (),
+                          NULL, NULL, NULL, NULL, NULL, NULL);
 
   /* Fall-through.  */
  leave:
diff --git a/src/gpgex.cc b/src/gpgex.cc
index 8c973d8..84e9901 100644
--- a/src/gpgex.cc
+++ b/src/gpgex.cc
@@ -164,87 +164,69 @@ gpgex_t::Initialize (LPCITEMIDLIST pIDFolder, IDataObject *pDataObj,
 
   this->reset ();
 
-  try
+  if (pDataObj)
     {
-      if (pDataObj)
-	{
-	  /* The data object contains a drop item which we extract.  */
-	  FORMATETC fe = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
-	  STGMEDIUM medium;
-	  UINT count;
-
-	  if (SUCCEEDED (pDataObj->GetData (&fe, &medium)))
-	    {
-	      HDROP drop = (HDROP) GlobalLock (medium.hGlobal);
-	      unsigned int i;
-
-	      /* Now that we have the drop item, we can extract the
-		 file names.  */
-	      count = DragQueryFile (drop, (UINT) -1, NULL, 0);
-	      if (count == 0)
-		throw std::invalid_argument ("no filenames");
-
-	      try
-		{
-		  for (i = 0; i < count; i++)
-		    {
-		      char filename[MAX_PATH];
-		      UINT len;
-		      len = DragQueryFile (drop, i,
-					   filename, sizeof (filename) - 1);
-		      if (len == 0)
-			throw std::invalid_argument ("zero-length filename");
-
-		      /* Take a look at the ending.  */
-		      char *ending = strrchr (filename, '.');
-		      if (ending)
-			{
-			  BOOL gpg = false;
-
-			  ending++;
-			  if (! strcasecmp (ending, "gpg")
-			      || ! strcasecmp (ending, "pgp")
-			      || ! strcasecmp (ending, "asc")
-			      || ! strcasecmp (ending, "sig")
-			      || ! strcasecmp (ending, "pem")
-			      || ! strcasecmp (ending, "p7m")
-			      || ! strcasecmp (ending, "p7s")
-                              )
-			    gpg = true;
-
-			  if (gpg == false)
-			    this->all_files_gpg = FALSE;
-			}
-		      else
-			this->all_files_gpg = FALSE;
-
-		      this->filenames.push_back (filename);
-		    }
-		}
-	      catch (...)
-		{
-		  GlobalUnlock (medium.hGlobal);
-		  ReleaseStgMedium (&medium);
-		  throw;
-		}
-
-	      GlobalUnlock (medium.hGlobal);
-	      ReleaseStgMedium (&medium);
-	    }
-	}
-    }
-  catch (std::bad_alloc)
-    {
-      err = E_OUTOFMEMORY;
-    }
-  catch (std::invalid_argument &e)
-    {
-      (VOID) TRACE_LOG1 ("exception: E_INVALIDARG: %s", e.what ());
-      err = E_INVALIDARG;
-    }
-  catch (...)
-    {
-      err = E_UNEXPECTED;
+      /* The data object contains a drop item which we extract.  */
+      FORMATETC fe = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
+      STGMEDIUM medium;
+      UINT count;
+
+      if (SUCCEEDED (pDataObj->GetData (&fe, &medium)))
+        {
+          HDROP drop = (HDROP) GlobalLock (medium.hGlobal);
+          unsigned int i;
+
+          /* Now that we have the drop item, we can extract the
+             file names.  */
+          count = DragQueryFile (drop, (UINT) -1, NULL, 0);
+          if (count == 0)
+            {
+              err = E_INVALIDARG;
+            }
+
+          if (!err)
+            {
+
+              for (i = 0; i < count; i++)
+                {
+                  char filename[MAX_PATH];
+                  UINT len;
+                  len = DragQueryFile (drop, i,
+                                       filename, sizeof (filename) - 1);
+                  if (len == 0)
+                    {
+                      err = E_INVALIDARG;
+                      break;
+                    }
+                  /* Take a look at the ending.  */
+                  char *ending = strrchr (filename, '.');
+                  if (ending)
+                    {
+                      BOOL gpg = false;
+
+                      ending++;
+                      if (! strcasecmp (ending, "gpg")
+                          || ! strcasecmp (ending, "pgp")
+                          || ! strcasecmp (ending, "asc")
+                          || ! strcasecmp (ending, "sig")
+                          || ! strcasecmp (ending, "pem")
+                          || ! strcasecmp (ending, "p7m")
+                          || ! strcasecmp (ending, "p7s")
+                          )
+                        gpg = true;
+
+                      if (gpg == false)
+                        this->all_files_gpg = FALSE;
+                    }
+                  else
+                    this->all_files_gpg = FALSE;
+
+                  this->filenames.push_back (filename);
+                }
+              GlobalUnlock (medium.hGlobal);
+              ReleaseStgMedium (&medium);
+            }
+        }
     }
 
   if (err != S_OK)

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

Summary of changes:
 configure.ac  |   3 ++
 src/client.cc |  51 +++++++++------------
 src/gpgex.cc  | 142 +++++++++++++++++++++++++---------------------------------
 3 files changed, 85 insertions(+), 111 deletions(-)


hooks/post-receive
-- 
GnupG extension for the Windows Explorer
http://git.gnupg.org




More information about the Gnupg-commits mailing list