[git] GPA - branch, master, updated. gpa-0.9.4-10-gd3f20e7

by Werner Koch cvs at cvs.gnupg.org
Fri Aug 16 16:45:14 CEST 2013


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 "The GNU Privacy Assistant".

The branch, master has been updated
       via  d3f20e7883f2fb9e52e487fd516bdc7b9bc695ed (commit)
       via  8e7043438fe42864b2413345b2cda8be29b08bf8 (commit)
       via  da655ad040fed39fa8e93e0d27fe6700f1cdf373 (commit)
       via  eaa716883eff8c9611f06fea5bc989b6e342964e (commit)
      from  398fd028c762dd6c0fc7a5945f55eb2dbd2edaec (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 d3f20e7883f2fb9e52e487fd516bdc7b9bc695ed
Author: Werner Koch <wk at gnupg.org>
Date:   Fri Aug 16 15:18:57 2013 +0200

    w32: Fix crash due to bad conversions of utf-8 in the clipboard.
    
    * src/gpgmetools.c (dos_to_unix): Remove.  Remove all calls.
    (dump_data_to_clipboard): Return an error code instead of calling
    exit.
    * src/gpaexportclipop.c
    (gpa_export_clipboard_operation_complete_export): Print success
    message only on success.
    --
    
    The removal of dos_to_unix is possible due to the patch
    https://bugzilla.gnome.org/show_bug.cgi?id=649390 which will go into
    the next Gtk+ 2.24 version.dos_to_unix was anyway not correct because
    it scanned for an embedded nul but it is not guaranteed that it is
    always called with one.
    
    The other patch which will be helpful is:
    https://bugzilla.gnome.org/show_bug.cgi?id=696232
    (g_utf8_to_utf16() is not guaranteed to succeed. Check the error and
     return if it failed.)
    
    Gpg4win uses both patches.
    
    GnuPG-bug-id: 1525

diff --git a/src/clipboard.c b/src/clipboard.c
index 682bd34..01b6058 100644
--- a/src/clipboard.c
+++ b/src/clipboard.c
@@ -283,10 +283,6 @@ file_created_cb (GpaFileOperation *op, gpa_file_item_t item, gpointer data)
                        NULL, &len, NULL);
       if (str)
         {
-#ifdef G_OS_WIN32
-          dos_to_unix (str, &item->direct_out_len);
-#endif
-
           gtk_text_buffer_set_text (clipboard->text_buffer, str, len);
           g_free (str);
           return;
@@ -296,10 +292,6 @@ file_created_cb (GpaFileOperation *op, gpa_file_item_t item, gpointer data)
       /* Enough warnings: Try to show even with invalid encoding.  */
     }
 
-#ifdef G_OS_WIN32
-  dos_to_unix (item->direct_out, &item->direct_out_len);
-#endif
-
   gtk_text_buffer_set_text (clipboard->text_buffer,
 			    item->direct_out, item->direct_out_len);
 }
@@ -481,10 +473,6 @@ file_open (GtkAction *action, gpointer param)
       return;
     }
 
-#ifdef G_OS_WIN32
-  dos_to_unix (contents, &length);
-#endif
-
   gtk_text_buffer_set_text (clipboard->text_buffer, contents, length);
   g_free (contents);
 }
diff --git a/src/gpaexportclipop.c b/src/gpaexportclipop.c
index 0ce88af..62edb12 100644
--- a/src/gpaexportclipop.c
+++ b/src/gpaexportclipop.c
@@ -134,10 +134,10 @@ static void
 gpa_export_clipboard_operation_complete_export (GpaExportOperation *operation)
 {
   GpaExportClipboardOperation *op = GPA_EXPORT_CLIPBOARD_OPERATION (operation);
-  dump_data_to_clipboard (operation->dest, gtk_clipboard_get
-			  (GDK_SELECTION_CLIPBOARD));
-  gpa_window_message (_("The keys have been copied to the clipboard."),
-		      GPA_OPERATION (op)->window);
+  if (!dump_data_to_clipboard (operation->dest, gtk_clipboard_get
+                               (GDK_SELECTION_CLIPBOARD)))
+    gpa_window_message (_("The keys have been copied to the clipboard."),
+                        GPA_OPERATION (op)->window);
 }
 
 /* API */
diff --git a/src/gpgmetools.c b/src/gpgmetools.c
index 2b4be56..63f6b8d 100644
--- a/src/gpgmetools.c
+++ b/src/gpgmetools.c
@@ -294,37 +294,12 @@ gpa_gpgme_data_new_from_file (gpgme_data_t *data,
 }
 
 
-#ifdef G_OS_WIN32
-/* Convert newlines.  */
-void
-dos_to_unix (gchar *str, gsize *len)
-{
-  /* On Windows 2000, we need to convert \r\n to \n in the output for
-     cut & paste to work properly (otherwise, extra newlines will be
-     inserted).  */
-  gchar *src;
-  gchar *dst;
-
-  src = str;
-  dst = str;
-  while (*src)
-    {
-      if (src[0] == '\r' && src[1] == '\n')
-	src++;
-      *(dst++) = *(src++);
-    }
-  *dst = '\0';
-  *len = dst - str;
-}
-#endif
-
-
 /* Write the contents of the gpgme_data_t into the clipboard.  Assumes
-   that the data is ASCII.  */
-void
+   that the data is ASCII.  Return 0 on success.  */
+int
 dump_data_to_clipboard (gpgme_data_t data, GtkClipboard *clipboard)
 {
-  char buffer[128];
+  char buffer[512];
   int nread;
   gchar *text = NULL;
   size_t len = 0;
@@ -333,27 +308,23 @@ dump_data_to_clipboard (gpgme_data_t data, GtkClipboard *clipboard)
   if (nread == -1)
     {
       gpa_window_error (strerror (errno), NULL);
-      exit (EXIT_FAILURE);
+      return -1;
     }
   while ((nread = gpgme_data_read (data, buffer, sizeof (buffer))) > 0)
     {
-      text = g_realloc (text, len + nread);
+      text = g_realloc (text, len + nread + 1);
       strncpy (text + len, buffer, nread);
       len += nread;
     }
   if (nread == -1)
     {
       gpa_window_error (strerror (errno), NULL);
-      exit (EXIT_FAILURE);
+      return -1;
     }
 
-#ifdef G_OS_WIN32
-  dos_to_unix (text, &len);
-#endif
-
   gtk_clipboard_set_text (clipboard, text, (int)len);
   g_free (text);
-  return;
+  return 0;
 }
 
 
diff --git a/src/gpgmetools.h b/src/gpgmetools.h
index a4ce122..2c6877d 100644
--- a/src/gpgmetools.h
+++ b/src/gpgmetools.h
@@ -113,11 +113,6 @@ int gpa_open_output (const char *filename, gpgme_data_t *data,
 int gpa_open_input (const char *filename, gpgme_data_t *data,
 		    GtkWidget *parent);
 
-#ifdef G_OS_WIN32
-/* Convert newlines.  */
-void dos_to_unix (gchar *str, gsize *len);
-#endif
-
 /* Write the contents of the gpgme_data_t into the clipboard.  */
 int dump_data_to_clipboard (gpgme_data_t data, GtkClipboard *clipboard);
 

commit 8e7043438fe42864b2413345b2cda8be29b08bf8
Author: Werner Koch <wk at gnupg.org>
Date:   Fri Aug 16 15:44:55 2013 +0200

    Improve code readability.
    
    * src/server-access.c (server_get_key): Make error checking better
    readable.

diff --git a/src/gpgmetools.c b/src/gpgmetools.c
index a6ff3d8..2b4be56 100644
--- a/src/gpgmetools.c
+++ b/src/gpgmetools.c
@@ -138,7 +138,8 @@ gpa_gpgme_new (void)
 /* Write the contents of the gpgme_data_t object to the file.
    Receives a filehandle instead of the filename, so that the caller
    can make sure the file is accesible before putting anything into
-   data.  */
+   data.  This is only used for a TMP file, thus it is okay to
+   terminate the application on error. */
 void
 dump_data_to_file (gpgme_data_t data, FILE *file)
 {
diff --git a/src/gpgmetools.h b/src/gpgmetools.h
index d88e48e..a4ce122 100644
--- a/src/gpgmetools.h
+++ b/src/gpgmetools.h
@@ -119,7 +119,7 @@ void dos_to_unix (gchar *str, gsize *len);
 #endif
 
 /* Write the contents of the gpgme_data_t into the clipboard.  */
-void dump_data_to_clipboard (gpgme_data_t data, GtkClipboard *clipboard);
+int dump_data_to_clipboard (gpgme_data_t data, GtkClipboard *clipboard);
 
 /* Begin generation of a key with the given parameters.  It prepares
    the parameters required by Gpgme and returns whatever
diff --git a/src/server-access.c b/src/server-access.c
index 2164f28..94fe0ca 100644
--- a/src/server-access.c
+++ b/src/server-access.c
@@ -581,7 +581,7 @@ server_get_key (const gchar *server, const gchar *keyid,
     {
       /* Create an empty gpgme_data_t, so that we always return a valid one */
       err = gpgme_data_new (data);
-      if (gpg_err_code (err) != GPG_ERR_NO_ERROR)
+      if (err)
         gpa_gpgme_error (err);
       gpa_window_error (_("The keyserver you specified is not valid"), parent);
       return FALSE;
@@ -599,7 +599,7 @@ server_get_key (const gchar *server, const gchar *keyid,
   /* Read the output */
   /* No error checking: the import will take care of that. */
   err = gpa_gpgme_data_new_from_file (data, output_filename, parent);
-  if (gpg_err_code (err) != GPG_ERR_NO_ERROR)
+  if (err)
     gpa_gpgme_error (err);
   g_free (keyserver);
   /* Delete temp files */

commit da655ad040fed39fa8e93e0d27fe6700f1cdf373
Author: Werner Koch <wk at gnupg.org>
Date:   Fri Aug 16 15:42:37 2013 +0200

    Add noreturn attribute to gpa_gpgme_error.
    
    * src/gpgmetools.h (_gpa_gpgme_error): Add attribute.
    * src/gpa-key-details.c (gpa_key_details_find): Remove dead code.

diff --git a/src/gpa-key-details.c b/src/gpa-key-details.c
index da46476..c43c8ca 100644
--- a/src/gpa-key-details.c
+++ b/src/gpa-key-details.c
@@ -697,11 +697,7 @@ gpa_key_details_find (GtkWidget *keydetails, const char *pattern)
 
   err = gpgme_new (&ctx);
   if (err)
-    {
-      gpa_gpgme_error (err);
-      gpa_key_details_update (keydetails, NULL, 0);
-      return;
-    }
+    gpa_gpgme_error (err);
   gpgme_set_protocol (ctx, GPGME_PROTOCOL_OpenPGP);
 
   if (!gpgme_op_keylist_start (ctx, pattern, 0))
diff --git a/src/gpgmetools.h b/src/gpgmetools.h
index e8b2c34..d88e48e 100644
--- a/src/gpgmetools.h
+++ b/src/gpgmetools.h
@@ -72,7 +72,8 @@ typedef struct
    Better to use the macro instead of the function.  */
 #define gpa_gpgme_error(err) \
          do { _gpa_gpgme_error (err, __FILE__, __LINE__); } while (0)
-void _gpa_gpgme_error (gpg_error_t err, const char *file, int line);
+void _gpa_gpgme_error (gpg_error_t err,
+                       const char *file, int line) G_GNUC_NORETURN;
 
 /* The same as gpa_gpgme_error, without quitting.  */
 void gpa_gpgme_warning_ext (gpg_error_t err, const char *desc);

commit eaa716883eff8c9611f06fea5bc989b6e342964e
Author: Werner Koch <wk at gnupg.org>
Date:   Fri Aug 16 15:39:20 2013 +0200

    Remove unused function.
    
    * src/server.c (hextobyte): Remove.

diff --git a/src/server.c b/src/server.c
index 1ce9a89..9148338 100644
--- a/src/server.c
+++ b/src/server.c
@@ -1226,35 +1226,6 @@ cmd_getinfo (assuan_context_t ctx, char *line)
 }
 
 

-
-/* Convert two hexadecimal digits from STR to the value they
-   represent.  Returns -1 if one of the characters is not a
-   hexadecimal digit.  */
-static int
-hextobyte (const char *str)
-{
-  int val = 0;
-  int i;
-
-#define NROFHEXDIGITS 2
-  for (i = 0; i < NROFHEXDIGITS; i++)
-    {
-      if (*str >= '0' && *str <= '9')
-        val += *str - '0';
-      else if (*str >= 'A' && *str <= 'F')
-        val += 10 + *str - 'A';
-      else if (*str >= 'a' && *str <= 'f')
-        val += 10 + *str - 'a';
-      else
-        return -1;
-      if (i < NROFHEXDIGITS - 1)
-        val *= 16;
-      str++;
-    }
-  return val;
-}
-
-
 /* FILE <file> [--continued]
 
    Set the files on which to operate.

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

Summary of changes:
 src/clipboard.c       |   12 ------------
 src/gpa-key-details.c |    6 +-----
 src/gpaexportclipop.c |    8 ++++----
 src/gpgmetools.c      |   46 +++++++++-------------------------------------
 src/gpgmetools.h      |   10 +++-------
 src/server-access.c   |    4 ++--
 src/server.c          |   29 -----------------------------
 7 files changed, 19 insertions(+), 96 deletions(-)


hooks/post-receive
-- 
The GNU Privacy Assistant
http://git.gnupg.org




More information about the Gnupg-commits mailing list