mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-18 14:17:03 +01:00
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>
This commit is contained in:
parent
0367a4b8cf
commit
fabcf1440a
@ -822,8 +822,8 @@ agent_card_pksign (ctrl_t ctrl,
|
|||||||
const unsigned char *indata, size_t indatalen,
|
const unsigned char *indata, size_t indatalen,
|
||||||
unsigned char **r_buf, size_t *r_buflen)
|
unsigned char **r_buf, size_t *r_buflen)
|
||||||
{
|
{
|
||||||
int rc, i;
|
int rc;
|
||||||
char *p, line[ASSUAN_LINELENGTH];
|
char line[ASSUAN_LINELENGTH];
|
||||||
membuf_t data;
|
membuf_t data;
|
||||||
struct inq_needpin_s inqparm;
|
struct inq_needpin_s inqparm;
|
||||||
|
|
||||||
@ -835,10 +835,8 @@ agent_card_pksign (ctrl_t ctrl,
|
|||||||
if (indatalen*2 + 50 > DIM(line))
|
if (indatalen*2 + 50 > DIM(line))
|
||||||
return unlock_scd (ctrl, gpg_error (GPG_ERR_GENERAL));
|
return unlock_scd (ctrl, gpg_error (GPG_ERR_GENERAL));
|
||||||
|
|
||||||
sprintf (line, "SETDATA ");
|
bin2hex (indata, indatalen, stpcpy (line, "SETDATA "));
|
||||||
p = line + strlen (line);
|
|
||||||
for (i=0; i < indatalen ; i++, p += 2 )
|
|
||||||
sprintf (p, "%02X", indata[i]);
|
|
||||||
rc = assuan_transact (ctrl->scd_local->ctx, line,
|
rc = assuan_transact (ctrl->scd_local->ctx, line,
|
||||||
NULL, NULL, NULL, NULL, NULL, NULL);
|
NULL, NULL, NULL, NULL, NULL, NULL);
|
||||||
if (rc)
|
if (rc)
|
||||||
|
@ -3063,7 +3063,6 @@ ssh_identity_register (ctrl_t ctrl, ssh_key_type_spec_t *spec,
|
|||||||
char *comment = NULL;
|
char *comment = NULL;
|
||||||
char *key_fpr = NULL;
|
char *key_fpr = NULL;
|
||||||
const char *initial_errtext = NULL;
|
const char *initial_errtext = NULL;
|
||||||
unsigned int i;
|
|
||||||
struct pin_entry_info_s *pi = NULL, *pi2;
|
struct pin_entry_info_s *pi = NULL, *pi2;
|
||||||
|
|
||||||
err = ssh_key_grip (key, key_grip_raw);
|
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;
|
goto out;
|
||||||
|
|
||||||
/* Cache this passphrase. */
|
/* Cache this passphrase. */
|
||||||
for (i = 0; i < 20; i++)
|
bin2hex (key_grip_raw, 20, key_grip);
|
||||||
sprintf (key_grip + 2 * i, "%02X", key_grip_raw[i]);
|
|
||||||
|
|
||||||
err = agent_put_cache (key_grip, CACHE_MODE_SSH, pi->pin, ttl);
|
err = agent_put_cache (key_grip, CACHE_MODE_SSH, pi->pin, ttl);
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -94,14 +94,9 @@ agent_pkdecrypt (ctrl_t ctrl, const char *desc_text,
|
|||||||
goto leave;
|
goto leave;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
put_membuf_printf (outbuf, "(5:value%u:", (unsigned int)len);
|
||||||
char tmpbuf[60];
|
put_membuf (outbuf, buf, len);
|
||||||
|
put_membuf (outbuf, ")", 2);
|
||||||
sprintf (tmpbuf, "(5:value%u:", (unsigned int)len);
|
|
||||||
put_membuf (outbuf, tmpbuf, strlen (tmpbuf));
|
|
||||||
put_membuf (outbuf, buf, len);
|
|
||||||
put_membuf (outbuf, ")", 2);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ /* No smartcard, but a private key */
|
{ /* No smartcard, but a private key */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user