summaryrefslogtreecommitdiffstats
path: root/agent
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2014-12-02 14:13:53 +0100
committerWerner Koch <wk@gnupg.org>2014-12-02 14:13:53 +0100
commitfabcf1440a6900b9471f11e4f2a015e9f2d1a74c (patch)
tree4225436911e628900a6ccb36b790065d9a7256f5 /agent
parenttools: Improve watchgnupg portability. (diff)
downloadgnupg2-fabcf1440a6900b9471f11e4f2a015e9f2d1a74c.tar.xz
gnupg2-fabcf1440a6900b9471f11e4f2a015e9f2d1a74c.zip
agent: Replace some sprintf.
* agent/call-scd.c (agent_card_pksign): Replace sprintf by bin2hex. * agent/command-ssh.c (ssh_identity_register): Ditto. * agent/pkdecrypt.c (agent_pkdecrypt): Replace sprintf by put_membuf_printf. Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'agent')
-rw-r--r--agent/call-scd.c10
-rw-r--r--agent/command-ssh.c5
-rw-r--r--agent/pkdecrypt.c11
3 files changed, 8 insertions, 18 deletions
diff --git a/agent/call-scd.c b/agent/call-scd.c
index 289b2d95a..ade7ef1b9 100644
--- a/agent/call-scd.c
+++ b/agent/call-scd.c
@@ -822,8 +822,8 @@ agent_card_pksign (ctrl_t ctrl,
const unsigned char *indata, size_t indatalen,
unsigned char **r_buf, size_t *r_buflen)
{
- int rc, i;
- char *p, line[ASSUAN_LINELENGTH];
+ int rc;
+ char line[ASSUAN_LINELENGTH];
membuf_t data;
struct inq_needpin_s inqparm;
@@ -835,10 +835,8 @@ agent_card_pksign (ctrl_t ctrl,
if (indatalen*2 + 50 > DIM(line))
return unlock_scd (ctrl, gpg_error (GPG_ERR_GENERAL));
- sprintf (line, "SETDATA ");
- p = line + strlen (line);
- for (i=0; i < indatalen ; i++, p += 2 )
- sprintf (p, "%02X", indata[i]);
+ bin2hex (indata, indatalen, stpcpy (line, "SETDATA "));
+
rc = assuan_transact (ctrl->scd_local->ctx, line,
NULL, NULL, NULL, NULL, NULL, NULL);
if (rc)
diff --git a/agent/command-ssh.c b/agent/command-ssh.c
index 493011c2a..2d0051230 100644
--- a/agent/command-ssh.c
+++ b/agent/command-ssh.c
@@ -3063,7 +3063,6 @@ ssh_identity_register (ctrl_t ctrl, ssh_key_type_spec_t *spec,
char *comment = NULL;
char *key_fpr = NULL;
const char *initial_errtext = NULL;
- unsigned int i;
struct pin_entry_info_s *pi = NULL, *pi2;
err = ssh_key_grip (key, key_grip_raw);
@@ -3139,9 +3138,7 @@ ssh_identity_register (ctrl_t ctrl, ssh_key_type_spec_t *spec,
goto out;
/* Cache this passphrase. */
- for (i = 0; i < 20; i++)
- sprintf (key_grip + 2 * i, "%02X", key_grip_raw[i]);
-
+ bin2hex (key_grip_raw, 20, key_grip);
err = agent_put_cache (key_grip, CACHE_MODE_SSH, pi->pin, ttl);
if (err)
goto out;
diff --git a/agent/pkdecrypt.c b/agent/pkdecrypt.c
index 945de3c51..8c09b8c4e 100644
--- a/agent/pkdecrypt.c
+++ b/agent/pkdecrypt.c
@@ -94,14 +94,9 @@ agent_pkdecrypt (ctrl_t ctrl, const char *desc_text,
goto leave;
}
- {
- char tmpbuf[60];
-
- sprintf (tmpbuf, "(5:value%u:", (unsigned int)len);
- put_membuf (outbuf, tmpbuf, strlen (tmpbuf));
- put_membuf (outbuf, buf, len);
- put_membuf (outbuf, ")", 2);
- }
+ put_membuf_printf (outbuf, "(5:value%u:", (unsigned int)len);
+ put_membuf (outbuf, buf, len);
+ put_membuf (outbuf, ")", 2);
}
else
{ /* No smartcard, but a private key */