[svn] GnuPG - r4773 - in trunk: . agent common jnlib po

svn author wk cvs at cvs.gnupg.org
Tue May 27 14:04:11 CEST 2008


Author: wk
Date: 2008-05-27 14:03:50 +0200 (Tue, 27 May 2008)
New Revision: 4773

Modified:
   trunk/NEWS
   trunk/agent/ChangeLog
   trunk/agent/call-pinentry.c
   trunk/agent/command-ssh.c
   trunk/agent/command.c
   trunk/agent/divert-scd.c
   trunk/agent/gpg-agent.c
   trunk/agent/preset-passphrase.c
   trunk/agent/trustlist.c
   trunk/agent/w32main.c
   trunk/autogen.sh
   trunk/common/ChangeLog
   trunk/common/asshelp.c
   trunk/common/homedir.c
   trunk/common/i18n.c
   trunk/common/util.h
   trunk/jnlib/ChangeLog
   trunk/jnlib/argparse.c
   trunk/po/ChangeLog
   trunk/po/be.po
   trunk/po/ca.po
   trunk/po/cs.po
   trunk/po/da.po
   trunk/po/de.po
   trunk/po/el.po
   trunk/po/eo.po
   trunk/po/es.po
   trunk/po/et.po
   trunk/po/fi.po
   trunk/po/fr.po
   trunk/po/gl.po
   trunk/po/hu.po
   trunk/po/id.po
   trunk/po/it.po
   trunk/po/ja.po
   trunk/po/nb.po
   trunk/po/pl.po
   trunk/po/pt.po
   trunk/po/pt_BR.po
   trunk/po/ro.po
   trunk/po/ru.po
   trunk/po/sk.po
   trunk/po/sv.po
   trunk/po/tr.po
   trunk/po/zh_CN.po
   trunk/po/zh_TW.po
Log:
Fixed segv in gpg-agent (command marktrusted).
Replaced almost all free by xfree.
Translation fixes.


[The diff below has been truncated]

Modified: trunk/agent/ChangeLog
===================================================================
--- trunk/agent/ChangeLog	2008-05-26 16:48:05 UTC (rev 4772)
+++ trunk/agent/ChangeLog	2008-05-27 12:03:50 UTC (rev 4773)
@@ -1,3 +1,30 @@
+2008-05-27  Werner Koch  <wk at g10code.com>
+
+	* trustlist.c (insert_colons): Fix stupidly wrong allocation
+	computation. 
+
+2008-05-26  Werner Koch  <wk at g10code.com>
+
+	* gpg-agent.c (main): Re-initialize default assuan log stream if a
+	log file is used.
+
+	* trustlist.c (agent_marktrusted): Use xtryasprintf and xfree.
+
+	* gpg-agent.c (main, agent_deinit_default_ctrl): Always use xfree
+	because our asprintf is mapped to an xmalloc style function in
+	util.h. Replace xtrdup by xtrystrdup.
+	* w32main.c (build_argv): Ditto.
+	* preset-passphrase.c (preset_passphrase): Ditto.
+	* divert-scd.c (ask_for_card): Ditto.
+	* command.c (option_handler): Ditto.
+	* command-ssh.c (ssh_handler_request_identities): Ditto.
+	* call-pinentry.c (start_pinentry): Ditto.
+
+	* gpg-agent.c (start_connection_thread)
+	(start_connection_thread_ssh): Use pth_thread_id for useful output
+	under W32.
+	(pth_thread_id) [!PTH_HAVE_PTH_THREAD_ID]: New.
+
 2008-03-17  Werner Koch  <wk at g10code.com>
 
 	* agent.h (agent_inq_pinentry_launched): New prototype.

Modified: trunk/common/ChangeLog
===================================================================
--- trunk/common/ChangeLog	2008-05-26 16:48:05 UTC (rev 4772)
+++ trunk/common/ChangeLog	2008-05-27 12:03:50 UTC (rev 4773)
@@ -1,3 +1,13 @@
+2008-05-26  Werner Koch  <wk at g10code.com>
+
+	* asshelp.c (send_one_option, send_pinentry_environment): use
+	xfree and xtrystrdup.
+
+	* i18n.c (i18n_switchto_utf8) [USE_SIMPLE_GETTEXT]: Return NULL.
+
+	* homedir.c (gnupg_module_name): Add
+	GNUPG_MODULE_NAME_CONNECT_AGENT and GNUPG_MODULE_NAME_GPGCONF.
+
 2008-04-21  Werner Koch  <wk at g10code.com>
 
 	* http.c (http_wait_response) [W32]: Use DuplicateHandle because

Modified: trunk/jnlib/ChangeLog
===================================================================
--- trunk/jnlib/ChangeLog	2008-05-26 16:48:05 UTC (rev 4772)
+++ trunk/jnlib/ChangeLog	2008-05-27 12:03:50 UTC (rev 4773)
@@ -1,3 +1,7 @@
+2008-05-26  Werner Koch  <wk at g10code.com>
+
+	* argparse.c (usage): Make sure to print a trailing LF for usage(1).
+
 2008-04-08  Werner Koch  <wk at g10code.com>
 
 	* w32-gettext.c (gettext_select_utf8): New.

Modified: trunk/po/ChangeLog
===================================================================
--- trunk/po/ChangeLog	2008-05-26 16:48:05 UTC (rev 4772)
+++ trunk/po/ChangeLog	2008-05-27 12:03:50 UTC (rev 4773)
@@ -1,3 +1,9 @@
+2008-05-26  Werner Koch  <wk at g10code.com>
+
+	* de.po: Minor fixes submitted by Jan Seidel.  Fixes bug#916.
+
+	* it.po: Typo fix.  Fixes bug#920.
+
 2008-05-09  Werner Koch  <wk at g10code.com>
 
 	* de.po: Update.

Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2008-05-26 16:48:05 UTC (rev 4772)
+++ trunk/NEWS	2008-05-27 12:03:50 UTC (rev 4773)
@@ -7,13 +7,17 @@
  * New mechanisms "local" and "nodefault" for --auto-key-locate [gpg].
    Fixed a few problems with this option.
 
- * [W32] Initialize the socket subsystem for all keyserver helpers.
+ * [W32] Initialized the socket subsystem for all keyserver helpers.
 
  * New gpg2 command --locate-keys.
 
  * New gpg2 options --with-sig-list and --with-sig-check.
 
+ * Made gpgsm's --output option work with --export-secret-key-p12.
 
+ * gpg-connect-agent accepts commands given as command line arguments.
+
+
 Noteworthy changes in version 2.0.9 (2008-03-26)
 ------------------------------------------------
 

Modified: trunk/agent/call-pinentry.c
===================================================================
--- trunk/agent/call-pinentry.c	2008-05-26 16:48:05 UTC (rev 4772)
+++ trunk/agent/call-pinentry.c	2008-05-27 12:03:50 UTC (rev 4773)
@@ -319,7 +319,7 @@
 	return unlock_pinentry (out_of_core ());
       rc = assuan_transact (entry_ctx, optstr, NULL, NULL, NULL, NULL, NULL,
 			    NULL);
-      free (optstr);
+      xfree (optstr);
       if (rc)
 	return unlock_pinentry (rc);
     }
@@ -373,7 +373,7 @@
         {
           assuan_transact (entry_ctx, optstr, NULL, NULL, NULL, NULL, NULL,
                            NULL);
-          free (optstr);
+          xfree (optstr);
         }
     }
 

Modified: trunk/agent/command-ssh.c
===================================================================
--- trunk/agent/command-ssh.c	2008-05-26 16:48:05 UTC (rev 4772)
+++ trunk/agent/command-ssh.c	2008-05-27 12:03:50 UTC (rev 4773)
@@ -1960,7 +1960,7 @@
   if (ctrl_fp)
     fclose (ctrl_fp);
 
-  free (key_directory);
+  xfree (key_directory);
   xfree (key_path);
   xfree (buffer);
   xfree (key_type);
@@ -2430,7 +2430,7 @@
   xfree (pi);
   xfree (buffer);
   xfree (comment);
-  free (description); /* (asprintf allocated, thus regular free.)  */
+  xfree (description); 
 
   return err;
 }

Modified: trunk/agent/command.c
===================================================================
--- trunk/agent/command.c	2008-05-26 16:48:05 UTC (rev 4772)
+++ trunk/agent/command.c	2008-05-27 12:03:50 UTC (rev 4773)
@@ -1422,8 +1422,8 @@
   if (!strcmp (key, "display"))
     {
       if (ctrl->display)
-        free (ctrl->display);
-      ctrl->display = strdup (value);
+        xfree (ctrl->display);
+      ctrl->display = xtrystrdup (value);
       if (!ctrl->display)
         return out_of_core ();
     }
@@ -1432,8 +1432,8 @@
       if (!opt.keep_tty)
         {
           if (ctrl->ttyname)
-            free (ctrl->ttyname);
-          ctrl->ttyname = strdup (value);
+            xfree (ctrl->ttyname);
+          ctrl->ttyname = xtrystrdup (value);
           if (!ctrl->ttyname)
             return out_of_core ();
         }
@@ -1443,8 +1443,8 @@
       if (!opt.keep_tty)
         {
           if (ctrl->ttytype)
-            free (ctrl->ttytype);
-          ctrl->ttytype = strdup (value);
+            xfree (ctrl->ttytype);
+          ctrl->ttytype = xtrystrdup (value);
           if (!ctrl->ttytype)
             return out_of_core ();
         }
@@ -1452,32 +1452,32 @@
   else if (!strcmp (key, "lc-ctype"))
     {
       if (ctrl->lc_ctype)
-        free (ctrl->lc_ctype);
-      ctrl->lc_ctype = strdup (value);
+        xfree (ctrl->lc_ctype);
+      ctrl->lc_ctype = xtrystrdup (value);
       if (!ctrl->lc_ctype)
         return out_of_core ();
     }
   else if (!strcmp (key, "lc-messages"))
     {
       if (ctrl->lc_messages)
-        free (ctrl->lc_messages);
-      ctrl->lc_messages = strdup (value);
+        xfree (ctrl->lc_messages);
+      ctrl->lc_messages = xtrystrdup (value);
       if (!ctrl->lc_messages)
         return out_of_core ();
     }
   else if (!strcmp (key, "xauthority"))
     {
       if (ctrl->xauthority)
-        free (ctrl->xauthority);
-      ctrl->xauthority = strdup (value);
+        xfree (ctrl->xauthority);
+      ctrl->xauthority = xtrystrdup (value);
       if (!ctrl->xauthority)
         return out_of_core ();
     }
   else if (!strcmp (key, "pinentry-user-data"))
     {
       if (ctrl->pinentry_user_data)
-        free (ctrl->pinentry_user_data);
-      ctrl->pinentry_user_data = strdup (value);
+        xfree (ctrl->pinentry_user_data);
+      ctrl->pinentry_user_data = xtrystrdup (value);
       if (!ctrl->pinentry_user_data)
         return out_of_core ();
     }
@@ -1515,7 +1515,7 @@
             const char *line, size_t linelen)
 {
   ctrl_t ctrl = assuan_get_pointer (ctx);
-
+  
   /* Note that we only check for the uppercase name.  This allows to
      see the logging for debugging if using a non-upercase command
      name. */

Modified: trunk/agent/divert-scd.c
===================================================================
--- trunk/agent/divert-scd.c	2008-05-26 16:48:05 UTC (rev 4772)
+++ trunk/agent/divert-scd.c	2008-05-27 12:03:50 UTC (rev 4773)
@@ -120,7 +120,7 @@
           else
             {
               rc = agent_get_confirmation (ctrl, desc, NULL, NULL);
-              free (desc);
+              xfree (desc);
             }
         }
       if (rc)
@@ -293,7 +293,7 @@
                      info? "')":"") < 0)
         desc = NULL;
       rc = agent_askpin (ctrl, desc?desc:info, prompt, NULL, pi);
-      free (desc);
+      xfree (desc);
     }
 
   if (!rc)

Modified: trunk/agent/gpg-agent.c
===================================================================
--- trunk/agent/gpg-agent.c	2008-05-26 16:48:05 UTC (rev 4772)
+++ trunk/agent/gpg-agent.c	2008-05-27 12:03:50 UTC (rev 4773)
@@ -263,7 +263,14 @@
 }
 
 
+#ifndef PTH_HAVE_PTH_THREAD_ID
+static unsigned long pth_thread_id (void)
+{
+  return (unsigned long)pth_self ();
+}
+#endif
 
+
 
 /*
    Functions. 
@@ -840,6 +847,7 @@
                              |JNLIB_LOG_WITH_TIME
                              |JNLIB_LOG_WITH_PID));
       current_logfile = xstrdup (logfile);
+      assuan_set_assuan_log_stream (log_get_stream ());
     }
 
   /* Make sure that we have a default ttyname. */
@@ -1034,11 +1042,11 @@
 		      printf ("%s; export SSH_AGENT_PID;\n", infostr_ssh_pid);
 		    }
                 }
-              free (infostr); /* (Note that a vanilla free is here correct.) */
+              xfree (infostr); 
 	      if (opt.ssh_support)
 		{
-		  free (infostr_ssh_sock);
-		  free (infostr_ssh_pid);
+		  xfree (infostr_ssh_sock);
+		  xfree (infostr_ssh_pid);
 		}
               exit (0); 
             }
@@ -1132,31 +1140,33 @@
      and the request will fail anyway shortly after this
      initialization. */
   if (ctrl->display)
-    free (ctrl->display);
-  ctrl->display = default_display? strdup (default_display) : NULL;
+    xfree (ctrl->display);
+  ctrl->display = default_display? xtrystrdup (default_display) : NULL;
 
   if (ctrl->ttyname)
-    free (ctrl->ttyname);
-  ctrl->ttyname = default_ttyname? strdup (default_ttyname) : NULL;
+    xfree (ctrl->ttyname);
+  ctrl->ttyname = default_ttyname? xtrystrdup (default_ttyname) : NULL;
 
   if (ctrl->ttytype)
-    free (ctrl->ttytype);
-  ctrl->ttytype = default_ttytype? strdup (default_ttytype) : NULL;
+    xfree (ctrl->ttytype);
+  ctrl->ttytype = default_ttytype? xtrystrdup (default_ttytype) : NULL;
 
   if (ctrl->lc_ctype)
-    free (ctrl->lc_ctype);
-  ctrl->lc_ctype = default_lc_ctype? strdup (default_lc_ctype) : NULL;
+    xfree (ctrl->lc_ctype);
+  ctrl->lc_ctype = default_lc_ctype? xtrystrdup (default_lc_ctype) : NULL;
 
   if (ctrl->lc_messages)
-    free (ctrl->lc_messages);
-  ctrl->lc_messages = default_lc_messages? strdup (default_lc_messages) : NULL;
+    xfree (ctrl->lc_messages);
+  ctrl->lc_messages = default_lc_messages? xtrystrdup (default_lc_messages)
+                                    /**/ : NULL;
 
   if (ctrl->xauthority)
-    free (ctrl->xauthority);
-  ctrl->xauthority = default_xauthority? strdup (default_xauthority) : NULL;
+    xfree (ctrl->xauthority);
+  ctrl->xauthority = default_xauthority? xtrystrdup (default_xauthority)
+                                   /**/: NULL;
 
   if (ctrl->pinentry_user_data)
-    free (ctrl->pinentry_user_data);
+    xfree (ctrl->pinentry_user_data);
   ctrl->pinentry_user_data = NULL;
 }
 
@@ -1165,19 +1175,19 @@
 agent_deinit_default_ctrl (ctrl_t ctrl)
 {
   if (ctrl->display)
-    free (ctrl->display);
+    xfree (ctrl->display);
   if (ctrl->ttyname)
-    free (ctrl->ttyname);
+    xfree (ctrl->ttyname);
   if (ctrl->ttytype)
-    free (ctrl->ttytype);
+    xfree (ctrl->ttytype);
   if (ctrl->lc_ctype)
-    free (ctrl->lc_ctype);
+    xfree (ctrl->lc_ctype);
   if (ctrl->lc_messages)
-    free (ctrl->lc_messages);
+    xfree (ctrl->lc_messages);
   if (ctrl->xauthority)
-    free (ctrl->xauthority);
+    xfree (ctrl->xauthority);
   if (ctrl->pinentry_user_data)
-    free (ctrl->pinentry_user_data);
+    xfree (ctrl->pinentry_user_data);
 }
 
 /* Reread parts of the configuration.  Note, that this function is
@@ -1622,12 +1632,12 @@
   agent_init_default_ctrl (ctrl);
   if (opt.verbose)
     log_info (_("handler 0x%lx for fd %d started\n"), 
-              (long)pth_self (), FD2INT(ctrl->thread_startup.fd));
+              pth_thread_id (), FD2INT(ctrl->thread_startup.fd));
 
   start_command_handler (ctrl, GNUPG_INVALID_FD, ctrl->thread_startup.fd);
   if (opt.verbose)
     log_info (_("handler 0x%lx for fd %d terminated\n"), 
-              (long)pth_self (), FD2INT(ctrl->thread_startup.fd));
+              pth_thread_id (), FD2INT(ctrl->thread_startup.fd));
   
   agent_deinit_default_ctrl (ctrl);
   xfree (ctrl);
@@ -1647,12 +1657,12 @@
   agent_init_default_ctrl (ctrl);
   if (opt.verbose)
     log_info (_("ssh handler 0x%lx for fd %d started\n"),
-              (long)pth_self (), FD2INT(ctrl->thread_startup.fd));
+              pth_thread_id (), FD2INT(ctrl->thread_startup.fd));
 
   start_command_handler_ssh (ctrl, ctrl->thread_startup.fd);
   if (opt.verbose)
     log_info (_("ssh handler 0x%lx for fd %d terminated\n"),
-              (long)pth_self (), FD2INT(ctrl->thread_startup.fd));
+              pth_thread_id (), FD2INT(ctrl->thread_startup.fd));
   
   agent_deinit_default_ctrl (ctrl);
   xfree (ctrl);

Modified: trunk/agent/preset-passphrase.c
===================================================================
--- trunk/agent/preset-passphrase.c	2008-05-26 16:48:05 UTC (rev 4772)
+++ trunk/agent/preset-passphrase.c	2008-05-27 12:03:50 UTC (rev 4773)
@@ -205,7 +205,7 @@
     }
 
   wipememory (line, strlen (line));
-  free (line);
+  xfree (line);
 }
 
 
@@ -222,7 +222,7 @@
 		 gpg_strerror (gpg_error_from_syserror ()));
       return;
     }
-  free (line);
+  xfree (line);
 }
 
 

Modified: trunk/agent/trustlist.c
===================================================================
--- trunk/agent/trustlist.c	2008-05-26 16:48:05 UTC (rev 4772)
+++ trunk/agent/trustlist.c	2008-05-27 12:03:50 UTC (rev 4773)
@@ -463,8 +463,9 @@
 {
   char *buffer, *p;
   size_t n = strlen (string);
+  size_t nnew = n + (n+1)/2;
 
-  p = buffer = xtrymalloc ( n + (n+2)/3 + 1 );
+  p = buffer = xtrymalloc ( nnew + 1 );
   if (!buffer)
     return NULL;
   while (*string)
@@ -478,6 +479,7 @@
         }
     }
   *p = 0;
+  assert (strlen (buffer) <= nnew);
 
   return buffer;
 }
@@ -526,7 +528,7 @@
   fprformatted = insert_colons (fpr);
   if (!fprformatted)
     return out_of_core ();
-  if (asprintf (&desc,
+  desc = xtryasprintf (
                 /* TRANSLATORS: This prompt is shown by the Pinentry
                    and has one special property: A "%%0A" is used by
                    Pinentry to insert a line break.  The double
@@ -539,7 +541,8 @@
                 _("Please verify that the certificate identified as:%%0A"
                   "  \"%s\"%%0A"
                   "has the fingerprint:%%0A"
-                  "  %s"), name, fprformatted) < 0 )
+                  "  %s"), name, fprformatted);
+  if (!desc)
     {
       xfree (fprformatted);
       return out_of_core ();
@@ -549,7 +552,7 @@
      be hit if the fingerprint matches the one of the CA.  The other
      button is "the default "Cancel" of the Pinentry. */
   err = agent_get_confirmation (ctrl, desc, _("Correct"), NULL);
-  free (desc);
+  xfree (desc);
   /* If the user did not confirmed this, we return cancel here so that
      gpgsm may stop asking further questions.  We won't do this for
      the second question of course. */
@@ -562,7 +565,7 @@
 
 
 
-  if (asprintf (&desc,
+  desc = xtryasprintf (
                 /* TRANSLATORS: This prompt is shown by the Pinentry
                    and has one special property: A "%%0A" is used by
                    Pinentry to insert a line break.  The double
@@ -574,14 +577,15 @@
                 _("Do you ultimately trust%%0A"
                   "  \"%s\"%%0A"
                   "to correctly certify user certificates?"),
-                name) < 0 )
+                name);
+  if (!desc)
     {
       xfree (fprformatted);
       return out_of_core ();
     }
 
   err = agent_get_confirmation (ctrl, desc, _("Yes"), _("No"));
-  free (desc);
+  xfree (desc);
   if (err)
     {
       xfree (fprformatted);

Modified: trunk/agent/w32main.c
===================================================================
--- trunk/agent/w32main.c	2008-05-26 16:48:05 UTC (rev 4772)
+++ trunk/agent/w32main.c	2008-05-27 12:03:50 UTC (rev 4773)
@@ -92,10 +92,10 @@
         }
     }
 
-  argv = malloc (argc * sizeof *argv);
+  argv = xtrymalloc (argc * sizeof *argv);
   if (!argv)
     {
-      free (cmdline);
+      xfree (cmdline);
       return NULL;
     }
 

Modified: trunk/autogen.sh
===================================================================
--- trunk/autogen.sh	2008-05-26 16:48:05 UTC (rev 4772)
+++ trunk/autogen.sh	2008-05-27 12:03:50 UTC (rev 4773)
@@ -93,7 +93,7 @@
 	     --with-zlib=${w32root} \
 	     --with-regex=${w32root} \
              --with-pth-prefix=${w32root} \
-             --with-adns=${w32root}
+             --with-adns=${w32root} \
              --without-included-gettext "$@"
     rc=$?
     exit $rc

Modified: trunk/common/asshelp.c
===================================================================
--- trunk/common/asshelp.c	2008-05-26 16:48:05 UTC (rev 4772)
+++ trunk/common/asshelp.c	2008-05-27 12:03:50 UTC (rev 4773)
@@ -49,7 +49,7 @@
   else
     {
       err = assuan_transact (ctx, optstr, NULL, NULL, NULL, NULL, NULL, NULL);
-      free (optstr);
+      xfree (optstr);
     }
 
   return err;
@@ -119,7 +119,7 @@
   old_lc = setlocale (LC_CTYPE, NULL);
   if (old_lc)
     {
-      old_lc = strdup (old_lc);
+      old_lc = xtrystrdup (old_lc);
       if (!old_lc)
         return gpg_error_from_syserror ();
     }
@@ -134,7 +134,7 @@
   if (old_lc)
     {
       setlocale (LC_CTYPE, old_lc);
-      free (old_lc);
+      xfree (old_lc);
     }
 #endif
   if (err)
@@ -145,7 +145,7 @@
   old_lc = setlocale (LC_MESSAGES, NULL);
   if (old_lc)
     {
-      old_lc = strdup (old_lc);
+      old_lc = xtrystrdup (old_lc);
       if (!old_lc)




More information about the Gnupg-commits mailing list