[svn] GnuPG - r4821 - trunk/scd

svn author mo cvs at cvs.gnupg.org
Sun Aug 31 13:55:10 CEST 2008


Author: mo
Date: 2008-08-31 13:55:09 +0200 (Sun, 31 Aug 2008)
New Revision: 4821

Modified:
   trunk/scd/ChangeLog
   trunk/scd/app-openpgp.c
   trunk/scd/command.c
   trunk/scd/scdaemon.c
Log:
2008-08-30  Moritz  <moritz at gnu.org>

	* scdaemon.c (main): Use estream_asprintf instead of asprintf.
	* command.c (update_reader_status_file): Likewise.
	(cmd_serialno): Use estream_asprintf instead of asprintf
	and xfree instead of free to release memory allocated
	through (estream_)asprintf.
	(cmd_learn): Likewise.
	(pin_cb): Likewise.
	* app-openpgp.c (get_public_key): Likewise.



Modified: trunk/scd/ChangeLog
===================================================================
--- trunk/scd/ChangeLog	2008-08-28 14:57:25 UTC (rev 4820)
+++ trunk/scd/ChangeLog	2008-08-31 11:55:09 UTC (rev 4821)
@@ -1,3 +1,14 @@
+2008-08-30  Moritz  <moritz at gnu.org>
+
+	* scdaemon.c (main): Use estream_asprintf instead of asprintf.
+	* command.c (update_reader_status_file): Likewise.
+	(cmd_serialno): Use estream_asprintf instead of asprintf
+	and xfree instead of free to release memory allocated
+	through (estream_)asprintf.
+	(cmd_learn): Likewise.
+	(pin_cb): Likewise.
+	* app-openpgp.c (get_public_key): Likewise.
+
 2008-08-18  Werner Koch  <wk at g10code.com>
 
 	* app-openpgp.c (do_setattr): Fix test for v2 cards.

Modified: trunk/scd/app-openpgp.c
===================================================================
--- trunk/scd/app-openpgp.c	2008-08-28 14:57:25 UTC (rev 4820)
+++ trunk/scd/app-openpgp.c	2008-08-31 11:55:09 UTC (rev 4821)
@@ -1093,9 +1093,9 @@
 	}
       hexkeyid = fpr + 24;
 
-      ret = asprintf (&command,
-		      "gpg --list-keys --with-colons --with-key-data '%s'",
-		      fpr);
+      ret = estream_asprintf (&command,
+			      "gpg --list-keys --with-colons --with-key-data '%s'",
+			      fpr);
       if (ret < 0)
 	{
 	  err = gpg_error_from_syserror ();
@@ -1103,7 +1103,7 @@
 	}
 
       fp = popen (command, "r");
-      free (command);
+      xfree (command);
       if (!fp)
 	{
 	  err = gpg_error_from_syserror ();

Modified: trunk/scd/command.c
===================================================================
--- trunk/scd/command.c	2008-08-28 14:57:25 UTC (rev 4820)
+++ trunk/scd/command.c	2008-08-31 11:55:09 UTC (rev 4821)
@@ -471,13 +471,13 @@
   if (rc)
     return rc;
 
-  rc = asprintf (&serial_and_stamp, "%s %lu", serial, (unsigned long)stamp);
+  rc = estream_asprintf (&serial_and_stamp, "%s %lu", serial, (unsigned long)stamp);
   xfree (serial);
   if (rc < 0)
     return out_of_core ();
   rc = 0;
   assuan_write_status (ctx, "SERIALNO", serial_and_stamp);
-  free (serial_and_stamp);
+  xfree (serial_and_stamp);
   return 0;
 }
 
@@ -567,7 +567,7 @@
     rc = app_get_serial_and_stamp (ctrl->app_ctx, &serial, &stamp);
     if (rc)
       return rc;
-    rc = asprintf (&serial_and_stamp, "%s %lu", serial, (unsigned long)stamp);
+    rc = estream_asprintf (&serial_and_stamp, "%s %lu", serial, (unsigned long)stamp);
     xfree (serial);
     if (rc < 0)
       return out_of_core ();
@@ -578,26 +578,26 @@
       {
         char *command;
 
-        rc = asprintf (&command, "KNOWNCARDP %s", serial_and_stamp);
+        rc = estream_asprintf (&command, "KNOWNCARDP %s", serial_and_stamp);
         if (rc < 0)
           {
-            free (serial_and_stamp);
+            xfree (serial_and_stamp);
             return out_of_core ();
           }
         rc = 0;
         rc = assuan_inquire (ctx, command, NULL, NULL, 0); 
-        free (command);  /* (must use standard free here) */
+        xfree (command);
         if (rc)
           {
             if (gpg_err_code (rc) != GPG_ERR_ASS_CANCELED)
               log_error ("inquire KNOWNCARDP failed: %s\n",
                          gpg_strerror (rc));
-            free (serial_and_stamp);
+            xfree (serial_and_stamp);
             return rc; 
           }
         /* not canceled, so we have to proceeed */
       }
-    free (serial_and_stamp);
+    xfree (serial_and_stamp);
   }
 
   /* Let the application print out its collection of useful status
@@ -784,11 +784,11 @@
       if (info)
         {
           log_debug ("prompting for keypad entry '%s'\n", info);
-          rc = asprintf (&command, "POPUPKEYPADPROMPT %s", info);
+          rc = estream_asprintf (&command, "POPUPKEYPADPROMPT %s", info);
           if (rc < 0)
             return gpg_error (gpg_err_code_from_errno (errno));
           rc = assuan_inquire (ctx, command, &value, &valuelen, MAXLEN_PIN); 
-          free (command);  
+          xfree (command);  
         }
       else
         {
@@ -804,14 +804,14 @@
   *retstr = NULL;
   log_debug ("asking for PIN '%s'\n", info);
 
-  rc = asprintf (&command, "NEEDPIN %s", info);
+  rc = estream_asprintf (&command, "NEEDPIN %s", info);
   if (rc < 0)
     return gpg_error (gpg_err_code_from_errno (errno));
 
   /* Fixme: Write an inquire function which returns the result in
      secure memory and check all further handling of the PIN. */
   rc = assuan_inquire (ctx, command, &value, &valuelen, MAXLEN_PIN); 
-  free (command);  
+  xfree (command);  
   if (rc)
     return rc;
 
@@ -1918,7 +1918,7 @@
             gpg_error_t err;
             
             homestr = make_filename (opt.homedir, NULL);
-            if (asprintf (&envstr, "GNUPGHOME=%s", homestr) < 0)
+            if (estream_asprintf (&envstr, "GNUPGHOME=%s", homestr) < 0)
               log_error ("out of core while building environment\n");
             else
               {
@@ -1946,7 +1946,7 @@
                   log_error ("failed to run event handler `%s': %s\n",
                              fname, gpg_strerror (err));
                 xfree (fname);
-                free (envstr);
+                xfree (envstr);
               }
             xfree (homestr);
           }

Modified: trunk/scd/scdaemon.c
===================================================================
--- trunk/scd/scdaemon.c	2008-08-28 14:57:25 UTC (rev 4820)
+++ trunk/scd/scdaemon.c	2008-08-31 11:55:09 UTC (rev 4821)
@@ -702,8 +702,8 @@
           close (fd);
           
           /* create the info string: <name>:<pid>:<protocol_version> */
-          if (asprintf (&infostr, "SCDAEMON_INFO=%s:%lu:1",
-                        socket_name, (ulong)pid ) < 0)
+          if (estream_asprintf (&infostr, "SCDAEMON_INFO=%s:%lu:1",
+				socket_name, (ulong) pid) < 0)
             {
               log_error ("out of core\n");
               kill (pid, SIGTERM);
@@ -738,7 +738,7 @@
                 {
                   printf ( "%s; export SCDAEMON_INFO;\n", infostr);
                 }
-              free (infostr);
+              xfree (infostr);
               exit (0); 
             }
           /* NOTREACHED */




More information about the Gnupg-commits mailing list