aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--scd/ChangeLog11
-rw-r--r--scd/app-openpgp.c8
-rw-r--r--scd/command.c28
-rw-r--r--scd/scdaemon.c6
4 files changed, 32 insertions, 21 deletions
diff --git a/scd/ChangeLog b/scd/ChangeLog
index 1c453e826..ee340540f 100644
--- a/scd/ChangeLog
+++ b/scd/ChangeLog
@@ -1,3 +1,14 @@
+2008-08-30 Moritz <[email protected]>
+
+ * 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 <[email protected]>
* app-openpgp.c (do_setattr): Fix test for v2 cards.
diff --git a/scd/app-openpgp.c b/scd/app-openpgp.c
index 553d2fe8c..1750668f4 100644
--- a/scd/app-openpgp.c
+++ b/scd/app-openpgp.c
@@ -1093,9 +1093,9 @@ get_public_key (app_t app, int keyno)
}
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 @@ get_public_key (app_t app, int keyno)
}
fp = popen (command, "r");
- free (command);
+ xfree (command);
if (!fp)
{
err = gpg_error_from_syserror ();
diff --git a/scd/command.c b/scd/command.c
index 7fefea7b4..418ad001e 100644
--- a/scd/command.c
+++ b/scd/command.c
@@ -471,13 +471,13 @@ cmd_serialno (assuan_context_t ctx, char *line)
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 @@ cmd_learn (assuan_context_t ctx, char *line)
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 @@ cmd_learn (assuan_context_t ctx, char *line)
{
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 @@ pin_cb (void *opaque, const char *info, char **retstr)
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 @@ pin_cb (void *opaque, const char *info, char **retstr)
*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 @@ update_reader_status_file (void)
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 @@ update_reader_status_file (void)
log_error ("failed to run event handler `%s': %s\n",
fname, gpg_strerror (err));
xfree (fname);
- free (envstr);
+ xfree (envstr);
}
xfree (homestr);
}
diff --git a/scd/scdaemon.c b/scd/scdaemon.c
index a8a3bcff5..68119f592 100644
--- a/scd/scdaemon.c
+++ b/scd/scdaemon.c
@@ -702,8 +702,8 @@ main (int argc, char **argv )
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 @@ main (int argc, char **argv )
{
printf ( "%s; export SCDAEMON_INFO;\n", infostr);
}
- free (infostr);
+ xfree (infostr);
exit (0);
}
/* NOTREACHED */