1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-05-27 21:41:23 +02:00

Fix use cases of snprintf.

* agent/call-pinentry.c, agent/call-scd.c, agent/command.c,
build-aux/speedo/w32/g4wihelp.c, common/get-passphrase.c,
dirmngr/dirmngr.c, g10/call-agent.c, g10/cpr.c, g10/keygen.c,
g10/openfile.c, g10/passphrase.c, scd/app-openpgp.c, scd/scdaemon.c,
sm/call-agent.c, sm/call-dirmngr.c, sm/certreqgen.c: Fix assuming C99.

--
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2016-10-21 12:04:46 +09:00
parent 1ffd475f99
commit 6e85ac77af
16 changed files with 97 additions and 157 deletions

View File

@ -734,8 +734,7 @@ setup_qualitybar (ctrl_t ctrl)
/* TRANSLATORS: This string is displayed by Pinentry as the label /* TRANSLATORS: This string is displayed by Pinentry as the label
for the quality bar. */ for the quality bar. */
tmpstr = try_percent_escape (L_("Quality:"), "\t\r\n\f\v"); tmpstr = try_percent_escape (L_("Quality:"), "\t\r\n\f\v");
snprintf (line, DIM(line)-1, "SETQUALITYBAR %s", tmpstr? tmpstr:""); snprintf (line, DIM(line), "SETQUALITYBAR %s", tmpstr? tmpstr:"");
line[DIM(line)-1] = 0;
xfree (tmpstr); xfree (tmpstr);
rc = assuan_transact (entry_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL); rc = assuan_transact (entry_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
if (rc == 103 /*(Old assuan error code)*/ if (rc == 103 /*(Old assuan error code)*/
@ -763,8 +762,7 @@ setup_qualitybar (ctrl_t ctrl)
} }
tmpstr = try_percent_escape (tooltip, "\t\r\n\f\v"); tmpstr = try_percent_escape (tooltip, "\t\r\n\f\v");
xfree (tmpstr2); xfree (tmpstr2);
snprintf (line, DIM(line)-1, "SETQUALITYBAR_TT %s", tmpstr? tmpstr:""); snprintf (line, DIM(line), "SETQUALITYBAR_TT %s", tmpstr? tmpstr:"");
line[DIM(line)-1] = 0;
xfree (tmpstr); xfree (tmpstr);
rc = assuan_transact (entry_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL); rc = assuan_transact (entry_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
if (rc == 103 /*(Old assuan error code)*/ if (rc == 103 /*(Old assuan error code)*/
@ -887,27 +885,25 @@ agent_askpin (ctrl_t ctrl,
if (keyinfo && (cache_mode == CACHE_MODE_NORMAL if (keyinfo && (cache_mode == CACHE_MODE_NORMAL
|| cache_mode == CACHE_MODE_USER || cache_mode == CACHE_MODE_USER
|| cache_mode == CACHE_MODE_SSH)) || cache_mode == CACHE_MODE_SSH))
snprintf (line, DIM(line)-1, "SETKEYINFO %c/%s", snprintf (line, DIM(line), "SETKEYINFO %c/%s",
cache_mode == CACHE_MODE_USER? 'u' : cache_mode == CACHE_MODE_USER? 'u' :
cache_mode == CACHE_MODE_SSH? 's' : 'n', cache_mode == CACHE_MODE_SSH? 's' : 'n',
keyinfo); keyinfo);
else else
snprintf (line, DIM(line)-1, "SETKEYINFO --clear"); snprintf (line, DIM(line), "SETKEYINFO --clear");
rc = assuan_transact (entry_ctx, line, rc = assuan_transact (entry_ctx, line,
NULL, NULL, NULL, NULL, NULL, NULL); NULL, NULL, NULL, NULL, NULL, NULL);
if (rc && gpg_err_code (rc) != GPG_ERR_ASS_UNKNOWN_CMD) if (rc && gpg_err_code (rc) != GPG_ERR_ASS_UNKNOWN_CMD)
return unlock_pinentry (rc); return unlock_pinentry (rc);
snprintf (line, DIM(line)-1, "SETDESC %s", desc_text); snprintf (line, DIM(line), "SETDESC %s", desc_text);
line[DIM(line)-1] = 0;
rc = assuan_transact (entry_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL); rc = assuan_transact (entry_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
if (rc) if (rc)
return unlock_pinentry (rc); return unlock_pinentry (rc);
snprintf (line, DIM(line)-1, "SETPROMPT %s", snprintf (line, DIM(line), "SETPROMPT %s",
prompt_text? prompt_text : is_pin? L_("PIN:") : L_("Passphrase:")); prompt_text? prompt_text : is_pin? L_("PIN:") : L_("Passphrase:"));
line[DIM(line)-1] = 0;
rc = assuan_transact (entry_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL); rc = assuan_transact (entry_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
if (rc) if (rc)
return unlock_pinentry (rc); return unlock_pinentry (rc);
@ -924,8 +920,7 @@ agent_askpin (ctrl_t ctrl,
if (initial_errtext) if (initial_errtext)
{ {
snprintf (line, DIM(line)-1, "SETERROR %s", initial_errtext); snprintf (line, DIM(line), "SETERROR %s", initial_errtext);
line[DIM(line)-1] = 0;
rc = assuan_transact (entry_ctx, line, rc = assuan_transact (entry_ctx, line,
NULL, NULL, NULL, NULL, NULL, NULL); NULL, NULL, NULL, NULL, NULL, NULL);
if (rc) if (rc)
@ -934,9 +929,8 @@ agent_askpin (ctrl_t ctrl,
if (pininfo->with_repeat) if (pininfo->with_repeat)
{ {
snprintf (line, DIM(line)-1, "SETREPEATERROR %s", snprintf (line, DIM(line), "SETREPEATERROR %s",
L_("does not match - try again")); L_("does not match - try again"));
line[DIM(line)-1] = 0;
rc = assuan_transact (entry_ctx, line, rc = assuan_transact (entry_ctx, line,
NULL, NULL, NULL, NULL, NULL, NULL); NULL, NULL, NULL, NULL, NULL, NULL);
if (rc) if (rc)
@ -956,9 +950,8 @@ agent_askpin (ctrl_t ctrl,
/* TRANSLATORS: The string is appended to an error message in /* TRANSLATORS: The string is appended to an error message in
the pinentry. The %s is the actual error message, the the pinentry. The %s is the actual error message, the
two %d give the current and maximum number of tries. */ two %d give the current and maximum number of tries. */
snprintf (line, DIM(line)-1, L_("SETERROR %s (try %d of %d)"), snprintf (line, DIM(line), L_("SETERROR %s (try %d of %d)"),
errtext, pininfo->failed_tries+1, pininfo->max_tries); errtext, pininfo->failed_tries+1, pininfo->max_tries);
line[DIM(line)-1] = 0;
rc = assuan_transact (entry_ctx, line, rc = assuan_transact (entry_ctx, line,
NULL, NULL, NULL, NULL, NULL, NULL); NULL, NULL, NULL, NULL, NULL, NULL);
if (rc) if (rc)
@ -968,8 +961,7 @@ agent_askpin (ctrl_t ctrl,
if (pininfo->with_repeat) if (pininfo->with_repeat)
{ {
snprintf (line, DIM(line)-1, "SETREPEAT %s", L_("Repeat:")); snprintf (line, DIM(line), "SETREPEAT %s", L_("Repeat:"));
line[DIM(line)-1] = 0;
rc = assuan_transact (entry_ctx, line, rc = assuan_transact (entry_ctx, line,
NULL, NULL, NULL, NULL, NULL, NULL); NULL, NULL, NULL, NULL, NULL, NULL);
if (rc) if (rc)
@ -1100,12 +1092,12 @@ agent_get_passphrase (ctrl_t ctrl,
if (keyinfo && (cache_mode == CACHE_MODE_NORMAL if (keyinfo && (cache_mode == CACHE_MODE_NORMAL
|| cache_mode == CACHE_MODE_USER || cache_mode == CACHE_MODE_USER
|| cache_mode == CACHE_MODE_SSH)) || cache_mode == CACHE_MODE_SSH))
snprintf (line, DIM(line)-1, "SETKEYINFO %c/%s", snprintf (line, DIM(line), "SETKEYINFO %c/%s",
cache_mode == CACHE_MODE_USER? 'u' : cache_mode == CACHE_MODE_USER? 'u' :
cache_mode == CACHE_MODE_SSH? 's' : 'n', cache_mode == CACHE_MODE_SSH? 's' : 'n',
keyinfo); keyinfo);
else else
snprintf (line, DIM(line)-1, "SETKEYINFO --clear"); snprintf (line, DIM(line), "SETKEYINFO --clear");
rc = assuan_transact (entry_ctx, line, rc = assuan_transact (entry_ctx, line,
NULL, NULL, NULL, NULL, NULL, NULL); NULL, NULL, NULL, NULL, NULL, NULL);
@ -1114,16 +1106,14 @@ agent_get_passphrase (ctrl_t ctrl,
if (desc) if (desc)
snprintf (line, DIM(line)-1, "SETDESC %s", desc); snprintf (line, DIM(line), "SETDESC %s", desc);
else else
snprintf (line, DIM(line)-1, "RESET"); snprintf (line, DIM(line), "RESET");
line[DIM(line)-1] = 0;
rc = assuan_transact (entry_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL); rc = assuan_transact (entry_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
if (rc) if (rc)
return unlock_pinentry (rc); return unlock_pinentry (rc);
snprintf (line, DIM(line)-1, "SETPROMPT %s", prompt); snprintf (line, DIM(line), "SETPROMPT %s", prompt);
line[DIM(line)-1] = 0;
rc = assuan_transact (entry_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL); rc = assuan_transact (entry_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
if (rc) if (rc)
return unlock_pinentry (rc); return unlock_pinentry (rc);
@ -1137,8 +1127,7 @@ agent_get_passphrase (ctrl_t ctrl,
if (errtext) if (errtext)
{ {
snprintf (line, DIM(line)-1, "SETERROR %s", errtext); snprintf (line, DIM(line), "SETERROR %s", errtext);
line[DIM(line)-1] = 0;
rc = assuan_transact (entry_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL); rc = assuan_transact (entry_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
if (rc) if (rc)
return unlock_pinentry (rc); return unlock_pinentry (rc);
@ -1205,10 +1194,9 @@ agent_get_confirmation (ctrl_t ctrl,
return rc; return rc;
if (desc) if (desc)
snprintf (line, DIM(line)-1, "SETDESC %s", desc); snprintf (line, DIM(line), "SETDESC %s", desc);
else else
snprintf (line, DIM(line)-1, "RESET"); snprintf (line, DIM(line), "RESET");
line[DIM(line)-1] = 0;
rc = assuan_transact (entry_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL); rc = assuan_transact (entry_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
/* Most pinentries out in the wild return the old Assuan error code /* Most pinentries out in the wild return the old Assuan error code
for canceled which gets translated to an assuan Cancel error and for canceled which gets translated to an assuan Cancel error and
@ -1221,8 +1209,7 @@ agent_get_confirmation (ctrl_t ctrl,
if (ok) if (ok)
{ {
snprintf (line, DIM(line)-1, "SETOK %s", ok); snprintf (line, DIM(line), "SETOK %s", ok);
line[DIM(line)-1] = 0;
rc = assuan_transact (entry_ctx, rc = assuan_transact (entry_ctx,
line, NULL, NULL, NULL, NULL, NULL, NULL); line, NULL, NULL, NULL, NULL, NULL, NULL);
if (rc) if (rc)
@ -1235,8 +1222,7 @@ agent_get_confirmation (ctrl_t ctrl,
the standard cancel. */ the standard cancel. */
if (with_cancel) if (with_cancel)
{ {
snprintf (line, DIM(line)-1, "SETNOTOK %s", notok); snprintf (line, DIM(line), "SETNOTOK %s", notok);
line[DIM(line)-1] = 0;
rc = assuan_transact (entry_ctx, rc = assuan_transact (entry_ctx,
line, NULL, NULL, NULL, NULL, NULL, NULL); line, NULL, NULL, NULL, NULL, NULL, NULL);
} }
@ -1245,8 +1231,7 @@ agent_get_confirmation (ctrl_t ctrl,
if (gpg_err_code (rc) == GPG_ERR_ASS_UNKNOWN_CMD) if (gpg_err_code (rc) == GPG_ERR_ASS_UNKNOWN_CMD)
{ {
snprintf (line, DIM(line)-1, "SETCANCEL %s", notok); snprintf (line, DIM(line), "SETCANCEL %s", notok);
line[DIM(line)-1] = 0;
rc = assuan_transact (entry_ctx, line, rc = assuan_transact (entry_ctx, line,
NULL, NULL, NULL, NULL, NULL, NULL); NULL, NULL, NULL, NULL, NULL, NULL);
} }
@ -1282,10 +1267,9 @@ agent_show_message (ctrl_t ctrl, const char *desc, const char *ok_btn)
return rc; return rc;
if (desc) if (desc)
snprintf (line, DIM(line)-1, "SETDESC %s", desc); snprintf (line, DIM(line), "SETDESC %s", desc);
else else
snprintf (line, DIM(line)-1, "RESET"); snprintf (line, DIM(line), "RESET");
line[DIM(line)-1] = 0;
rc = assuan_transact (entry_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL); rc = assuan_transact (entry_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
/* Most pinentries out in the wild return the old Assuan error code /* Most pinentries out in the wild return the old Assuan error code
for canceled which gets translated to an assuan Cancel error and for canceled which gets translated to an assuan Cancel error and
@ -1298,8 +1282,7 @@ agent_show_message (ctrl_t ctrl, const char *desc, const char *ok_btn)
if (ok_btn) if (ok_btn)
{ {
snprintf (line, DIM(line)-1, "SETOK %s", ok_btn); snprintf (line, DIM(line), "SETOK %s", ok_btn);
line[DIM(line)-1] = 0;
rc = assuan_transact (entry_ctx, line, NULL, NULL, NULL, rc = assuan_transact (entry_ctx, line, NULL, NULL, NULL,
NULL, NULL, NULL); NULL, NULL, NULL);
if (rc) if (rc)
@ -1354,18 +1337,16 @@ agent_popup_message_start (ctrl_t ctrl, const char *desc, const char *ok_btn)
return rc; return rc;
if (desc) if (desc)
snprintf (line, DIM(line)-1, "SETDESC %s", desc); snprintf (line, DIM(line), "SETDESC %s", desc);
else else
snprintf (line, DIM(line)-1, "RESET"); snprintf (line, DIM(line), "RESET");
line[DIM(line)-1] = 0;
rc = assuan_transact (entry_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL); rc = assuan_transact (entry_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
if (rc) if (rc)
return unlock_pinentry (rc); return unlock_pinentry (rc);
if (ok_btn) if (ok_btn)
{ {
snprintf (line, DIM(line)-1, "SETOK %s", ok_btn); snprintf (line, DIM(line), "SETOK %s", ok_btn);
line[DIM(line)-1] = 0;
rc = assuan_transact (entry_ctx, line, NULL,NULL,NULL,NULL,NULL,NULL); rc = assuan_transact (entry_ctx, line, NULL,NULL,NULL,NULL,NULL,NULL);
if (rc) if (rc)
return unlock_pinentry (rc); return unlock_pinentry (rc);
@ -1465,7 +1446,7 @@ agent_clear_passphrase (ctrl_t ctrl,
if (rc) if (rc)
return rc; return rc;
snprintf (line, DIM(line)-1, "CLEARPASSPHRASE %c/%s", snprintf (line, DIM(line), "CLEARPASSPHRASE %c/%s",
cache_mode == CACHE_MODE_USER? 'u' : cache_mode == CACHE_MODE_USER? 'u' :
cache_mode == CACHE_MODE_SSH? 's' : 'n', cache_mode == CACHE_MODE_SSH? 's' : 'n',
keyinfo); keyinfo);

View File

@ -946,8 +946,7 @@ agent_card_pkdecrypt (ctrl_t ctrl,
inqparm.getpin_cb_arg = getpin_cb_arg; inqparm.getpin_cb_arg = getpin_cb_arg;
inqparm.passthru = 0; inqparm.passthru = 0;
inqparm.any_inq_seen = 0; inqparm.any_inq_seen = 0;
snprintf (line, DIM(line)-1, "PKDECRYPT %s", keyid); snprintf (line, DIM(line), "PKDECRYPT %s", keyid);
line[DIM(line)-1] = 0;
rc = assuan_transact (ctrl->scd_local->ctx, line, rc = assuan_transact (ctrl->scd_local->ctx, line,
put_membuf_cb, &data, put_membuf_cb, &data,
inq_needpin, &inqparm, inq_needpin, &inqparm,
@ -986,8 +985,7 @@ agent_card_readcert (ctrl_t ctrl,
return rc; return rc;
init_membuf (&data, 1024); init_membuf (&data, 1024);
snprintf (line, DIM(line)-1, "READCERT %s", id); snprintf (line, DIM(line), "READCERT %s", id);
line[DIM(line)-1] = 0;
rc = assuan_transact (ctrl->scd_local->ctx, line, rc = assuan_transact (ctrl->scd_local->ctx, line,
put_membuf_cb, &data, put_membuf_cb, &data,
NULL, NULL, NULL, NULL,
@ -1022,8 +1020,7 @@ agent_card_readkey (ctrl_t ctrl, const char *id, unsigned char **r_buf)
return rc; return rc;
init_membuf (&data, 1024); init_membuf (&data, 1024);
snprintf (line, DIM(line)-1, "READKEY %s", id); snprintf (line, DIM(line), "READKEY %s", id);
line[DIM(line)-1] = 0;
rc = assuan_transact (ctrl->scd_local->ctx, line, rc = assuan_transact (ctrl->scd_local->ctx, line,
put_membuf_cb, &data, put_membuf_cb, &data,
NULL, NULL, NULL, NULL,
@ -1088,8 +1085,7 @@ agent_card_writekey (ctrl_t ctrl, int force, const char *serialno,
if (rc) if (rc)
return rc; return rc;
snprintf (line, DIM(line)-1, "WRITEKEY %s%s", force ? "--force " : "", id); snprintf (line, DIM(line), "WRITEKEY %s%s", force ? "--force " : "", id);
line[DIM(line)-1] = 0;
parms.ctx = ctrl->scd_local->ctx; parms.ctx = ctrl->scd_local->ctx;
parms.getpin_cb = getpin_cb; parms.getpin_cb = getpin_cb;
parms.getpin_cb_arg = getpin_cb_arg; parms.getpin_cb_arg = getpin_cb_arg;

View File

@ -369,7 +369,7 @@ agent_inq_pinentry_launched (ctrl_t ctrl, unsigned long pid)
if (!ctrl || !ctrl->server_local if (!ctrl || !ctrl->server_local
|| !ctrl->server_local->allow_pinentry_notify) || !ctrl->server_local->allow_pinentry_notify)
return 0; return 0;
snprintf (line, DIM(line)-1, "PINENTRY_LAUNCHED %lu", pid); snprintf (line, DIM(line), "PINENTRY_LAUNCHED %lu", pid);
return assuan_inquire (ctrl->server_local->assuan_ctx, line, NULL, NULL, 0); return assuan_inquire (ctrl->server_local->assuan_ctx, line, NULL, NULL, 0);
} }

View File

@ -70,12 +70,12 @@ dummy (HWND hwndParent, int string_size, char *variables,
// do your stuff here // do your stuff here
{ {
char buf[1024]; char buf[1024];
snprintf (buf, sizeof buf - 1, "$R0=%s\r\n$R1=%s\r\n", snprintf (buf, sizeof buf, "$R0=%s\r\n$R1=%s\r\n",
getuservariable(INST_R0), getuservariable(INST_R0),
getuservariable(INST_R1)); getuservariable(INST_R1));
MessageBox (g_hwndParent,buf,0,MB_OK); MessageBox (g_hwndParent,buf,0,MB_OK);
snprintf (buf, sizeof buf - 1, snprintf (buf, sizeof buf,
"autoclose =%d\r\n" "autoclose =%d\r\n"
"all_user_var =%d\r\n" "all_user_var =%d\r\n"
"exec_error =%d\r\n" "exec_error =%d\r\n"
@ -278,7 +278,7 @@ void
service_error (const char *str) service_error (const char *str)
{ {
char buf[1024]; char buf[1024];
snprintf (buf, sizeof (buf) - 1, "error: %s: ec=%d\r\n", str, snprintf (buf, sizeof (buf), "error: %s: ec=%d\r\n", str,
GetLastError ()); GetLastError ());
MessageBox(g_hwndParent, buf, 0, MB_OK); MessageBox(g_hwndParent, buf, 0, MB_OK);
@ -575,7 +575,7 @@ service_stop (HWND hwndParent, int string_size, char *variables,
if (GetTickCount () - start_time > timeout) if (GetTickCount () - start_time > timeout)
{ {
char buf[1024]; char buf[1024];
snprintf (buf, sizeof (buf) - 1, snprintf (buf, sizeof (buf),
"time out waiting for service %s to stop\r\n", "time out waiting for service %s to stop\r\n",
service_name); service_name);
MessageBox (g_hwndParent, buf, 0, MB_OK); MessageBox (g_hwndParent, buf, 0, MB_OK);

View File

@ -181,7 +181,7 @@ gnupg_get_passphrase (const char *cache_id,
if (!(arg4 = percent_plus_escape (desc_msg))) if (!(arg4 = percent_plus_escape (desc_msg)))
goto no_mem; goto no_mem;
snprintf (line, DIM(line)-1, snprintf (line, DIM(line),
"GET_PASSPHRASE --data %s--repeat=%d -- %s %s %s %s", "GET_PASSPHRASE --data %s--repeat=%d -- %s %s %s %s",
check_quality? "--check ":"", check_quality? "--check ":"",
repeat, repeat,
@ -189,7 +189,6 @@ gnupg_get_passphrase (const char *cache_id,
arg2? arg2:"X", arg2? arg2:"X",
arg3? arg3:"X", arg3? arg3:"X",
arg4? arg4:"X"); arg4? arg4:"X");
line[DIM(line)-1] = 0;
xfree (arg2); xfree (arg2);
xfree (arg3); xfree (arg3);
xfree (arg4); xfree (arg4);
@ -250,8 +249,7 @@ gnupg_clear_passphrase (const char *cache_id)
if (err) if (err)
return err; return err;
snprintf (line, DIM(line)-1, "CLEAR_PASSPHRASE %s", cache_id); snprintf (line, DIM(line), "CLEAR_PASSPHRASE %s", cache_id);
line[DIM(line)-1] = 0;
return assuan_transact (agent_ctx, line, NULL, NULL, return assuan_transact (agent_ctx, line, NULL, NULL,
default_inq_cb, NULL, NULL, NULL); default_inq_cb, NULL, NULL, NULL);
} }

View File

@ -2050,9 +2050,8 @@ handle_connections (assuan_fd_t listen_fd)
memset (&argval, 0, sizeof argval); memset (&argval, 0, sizeof argval);
argval.afd = fd; argval.afd = fd;
snprintf (threadname, sizeof threadname-1, snprintf (threadname, sizeof threadname,
"conn fd=%d", FD2INT(fd)); "conn fd=%d", FD2INT(fd));
threadname[sizeof threadname -1] = 0;
ret = npth_create (&thread, &tattr, ret = npth_create (&thread, &tattr,
start_connection_thread, argval.aptr); start_connection_thread, argval.aptr);

View File

@ -726,7 +726,7 @@ agent_scd_apdu (const char *hexapdu, unsigned int *r_sw)
init_membuf (&mb, 256); init_membuf (&mb, 256);
snprintf (line, DIM(line)-1, "SCD APDU %s", hexapdu); snprintf (line, DIM(line), "SCD APDU %s", hexapdu);
err = assuan_transact (agent_ctx, line, err = assuan_transact (agent_ctx, line,
put_membuf_cb, &mb, NULL, NULL, NULL, NULL); put_membuf_cb, &mb, NULL, NULL, NULL, NULL);
if (!err) if (!err)
@ -758,9 +758,8 @@ agent_keytocard (const char *hexgrip, int keyno, int force,
memset (&parm, 0, sizeof parm); memset (&parm, 0, sizeof parm);
snprintf (line, DIM(line)-1, "KEYTOCARD %s%s %s OPENPGP.%d %s", snprintf (line, DIM(line), "KEYTOCARD %s%s %s OPENPGP.%d %s",
force?"--force ": "", hexgrip, serialno, keyno, timestamp); force?"--force ": "", hexgrip, serialno, keyno, timestamp);
line[DIM(line)-1] = 0;
rc = start_agent (NULL, 1); rc = start_agent (NULL, 1);
if (rc) if (rc)
@ -902,8 +901,7 @@ agent_scd_writecert (const char *certidstr,
memset (&parms, 0, sizeof parms); memset (&parms, 0, sizeof parms);
snprintf (line, DIM(line)-1, "SCD WRITECERT %s", certidstr); snprintf (line, DIM(line), "SCD WRITECERT %s", certidstr);
line[DIM(line)-1] = 0;
dfltparm.ctx = agent_ctx; dfltparm.ctx = agent_ctx;
parms.dflt = &dfltparm; parms.dflt = &dfltparm;
parms.certdata = certdata; parms.certdata = certdata;
@ -956,8 +954,7 @@ agent_scd_writekey (int keyno, const char *serialno,
memset (&parms, 0, sizeof parms); memset (&parms, 0, sizeof parms);
snprintf (line, DIM(line)-1, "SCD WRITEKEY --force OPENPGP.%d", keyno); snprintf (line, DIM(line), "SCD WRITEKEY --force OPENPGP.%d", keyno);
line[DIM(line)-1] = 0;
dfltparm.ctx = agent_ctx; dfltparm.ctx = agent_ctx;
parms.dflt = &dfltparm; parms.dflt = &dfltparm;
parms.keydata = keydata; parms.keydata = keydata;
@ -1019,11 +1016,10 @@ agent_scd_genkey (int keyno, int force, u32 *createtime)
else else
*tbuf = 0; *tbuf = 0;
snprintf (line, DIM(line)-1, "SCD GENKEY %s%s %s %d", snprintf (line, DIM(line), "SCD GENKEY %s%s %s %d",
*tbuf? "--timestamp=":"", tbuf, *tbuf? "--timestamp=":"", tbuf,
force? "--force":"", force? "--force":"",
keyno); keyno);
line[DIM(line)-1] = 0;
dfltparm.ctx = agent_ctx; dfltparm.ctx = agent_ctx;
rc = assuan_transact (agent_ctx, line, rc = assuan_transact (agent_ctx, line,
@ -1151,8 +1147,7 @@ agent_scd_readcert (const char *certidstr,
init_membuf (&data, 2048); init_membuf (&data, 2048);
snprintf (line, DIM(line)-1, "SCD READCERT %s", certidstr); snprintf (line, DIM(line), "SCD READCERT %s", certidstr);
line[DIM(line)-1] = 0;
rc = assuan_transact (agent_ctx, line, rc = assuan_transact (agent_ctx, line,
put_membuf_cb, &data, put_membuf_cb, &data,
default_inq_cb, &dfltparm, default_inq_cb, &dfltparm,
@ -1202,8 +1197,7 @@ agent_scd_change_pin (int chvno, const char *serialno)
return rc; return rc;
dfltparm.ctx = agent_ctx; dfltparm.ctx = agent_ctx;
snprintf (line, DIM(line)-1, "SCD PASSWD %s %d", reset, chvno); snprintf (line, DIM(line), "SCD PASSWD %s %d", reset, chvno);
line[DIM(line)-1] = 0;
rc = assuan_transact (agent_ctx, line, rc = assuan_transact (agent_ctx, line,
NULL, NULL, NULL, NULL,
default_inq_cb, &dfltparm, default_inq_cb, &dfltparm,
@ -1230,8 +1224,7 @@ agent_scd_checkpin (const char *serialno)
return rc; return rc;
dfltparm.ctx = agent_ctx; dfltparm.ctx = agent_ctx;
snprintf (line, DIM(line)-1, "SCD CHECKPIN %s", serialno); snprintf (line, DIM(line), "SCD CHECKPIN %s", serialno);
line[DIM(line)-1] = 0;
rc = assuan_transact (agent_ctx, line, rc = assuan_transact (agent_ctx, line,
NULL, NULL, NULL, NULL,
default_inq_cb, &dfltparm, default_inq_cb, &dfltparm,
@ -1301,7 +1294,7 @@ agent_get_passphrase (const char *cache_id,
if (!(arg4 = percent_plus_escape (desc_msg))) if (!(arg4 = percent_plus_escape (desc_msg)))
goto no_mem; goto no_mem;
snprintf (line, DIM(line)-1, snprintf (line, DIM(line),
"GET_PASSPHRASE --data --repeat=%d%s -- %s %s %s %s", "GET_PASSPHRASE --data --repeat=%d%s -- %s %s %s %s",
repeat, repeat,
check? " --check --qualitybar":"", check? " --check --qualitybar":"",
@ -1309,7 +1302,6 @@ agent_get_passphrase (const char *cache_id,
arg2? arg2:"X", arg2? arg2:"X",
arg3? arg3:"X", arg3? arg3:"X",
arg4? arg4:"X"); arg4? arg4:"X");
line[DIM(line)-1] = 0;
xfree (arg1); xfree (arg1);
xfree (arg2); xfree (arg2);
xfree (arg3); xfree (arg3);
@ -1358,8 +1350,7 @@ agent_clear_passphrase (const char *cache_id)
return rc; return rc;
dfltparm.ctx = agent_ctx; dfltparm.ctx = agent_ctx;
snprintf (line, DIM(line)-1, "CLEAR_PASSPHRASE %s", cache_id); snprintf (line, DIM(line), "CLEAR_PASSPHRASE %s", cache_id);
line[DIM(line)-1] = 0;
return assuan_transact (agent_ctx, line, return assuan_transact (agent_ctx, line,
NULL, NULL, NULL, NULL,
default_inq_cb, &dfltparm, default_inq_cb, &dfltparm,
@ -1387,8 +1378,7 @@ gpg_agent_get_confirmation (const char *desc)
tmp = percent_plus_escape (desc); tmp = percent_plus_escape (desc);
if (!tmp) if (!tmp)
return gpg_error_from_syserror (); return gpg_error_from_syserror ();
snprintf (line, DIM(line)-1, "GET_CONFIRMATION %s", tmp); snprintf (line, DIM(line), "GET_CONFIRMATION %s", tmp);
line[DIM(line)-1] = 0;
xfree (tmp); xfree (tmp);
rc = assuan_transact (agent_ctx, line, rc = assuan_transact (agent_ctx, line,
@ -1574,8 +1564,7 @@ agent_get_keyinfo (ctrl_t ctrl, const char *hexkeygrip,
if (!hexkeygrip || strlen (hexkeygrip) != 40) if (!hexkeygrip || strlen (hexkeygrip) != 40)
return gpg_error (GPG_ERR_INV_VALUE); return gpg_error (GPG_ERR_INV_VALUE);
snprintf (line, DIM(line)-1, "KEYINFO %s", hexkeygrip); snprintf (line, DIM(line), "KEYINFO %s", hexkeygrip);
line[DIM(line)-1] = 0;
err = assuan_transact (agent_ctx, line, NULL, NULL, NULL, NULL, err = assuan_transact (agent_ctx, line, NULL, NULL, NULL, NULL,
keyinfo_status_cb, &keyinfo); keyinfo_status_cb, &keyinfo);
@ -1761,7 +1750,7 @@ agent_readkey (ctrl_t ctrl, int fromcard, const char *hexkeygrip,
if (err) if (err)
return err; return err;
snprintf (line, DIM(line)-1, "READKEY %s%s", fromcard? "--card ":"", snprintf (line, DIM(line), "READKEY %s%s", fromcard? "--card ":"",
hexkeygrip); hexkeygrip);
init_membuf (&data, 1024); init_membuf (&data, 1024);
@ -1826,16 +1815,14 @@ agent_pksign (ctrl_t ctrl, const char *cache_nonce,
if (err) if (err)
return err; return err;
snprintf (line, DIM(line)-1, "SIGKEY %s", keygrip); snprintf (line, DIM(line), "SIGKEY %s", keygrip);
line[DIM(line)-1] = 0;
err = assuan_transact (agent_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL); err = assuan_transact (agent_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
if (err) if (err)
return err; return err;
if (desc) if (desc)
{ {
snprintf (line, DIM(line)-1, "SETKEYDESC %s", desc); snprintf (line, DIM(line), "SETKEYDESC %s", desc);
line[DIM(line)-1] = 0;
err = assuan_transact (agent_ctx, line, err = assuan_transact (agent_ctx, line,
NULL, NULL, NULL, NULL, NULL, NULL); NULL, NULL, NULL, NULL, NULL, NULL);
if (err) if (err)
@ -1966,8 +1953,7 @@ agent_pkdecrypt (ctrl_t ctrl, const char *keygrip, const char *desc,
if (desc) if (desc)
{ {
snprintf (line, DIM(line)-1, "SETKEYDESC %s", desc); snprintf (line, DIM(line), "SETKEYDESC %s", desc);
line[DIM(line)-1] = 0;
err = assuan_transact (agent_ctx, line, err = assuan_transact (agent_ctx, line,
NULL, NULL, NULL, NULL, NULL, NULL); NULL, NULL, NULL, NULL, NULL, NULL);
if (err) if (err)
@ -2059,7 +2045,7 @@ agent_keywrap_key (ctrl_t ctrl, int forexport, void **r_kek, size_t *r_keklen)
return err; return err;
dfltparm.ctx = agent_ctx; dfltparm.ctx = agent_ctx;
snprintf (line, DIM(line)-1, "KEYWRAP_KEY %s", snprintf (line, DIM(line), "KEYWRAP_KEY %s",
forexport? "--export":"--import"); forexport? "--export":"--import");
init_membuf_secure (&data, 64); init_membuf_secure (&data, 64);
@ -2121,8 +2107,7 @@ agent_import_key (ctrl_t ctrl, const char *desc, char **cache_nonce_addr,
if (desc) if (desc)
{ {
snprintf (line, DIM(line)-1, "SETKEYDESC %s", desc); snprintf (line, DIM(line), "SETKEYDESC %s", desc);
line[DIM(line)-1] = 0;
err = assuan_transact (agent_ctx, line, err = assuan_transact (agent_ctx, line,
NULL, NULL, NULL, NULL, NULL, NULL); NULL, NULL, NULL, NULL, NULL, NULL);
if (err) if (err)
@ -2182,14 +2167,14 @@ agent_export_key (ctrl_t ctrl, const char *hexkeygrip, const char *desc,
if (desc) if (desc)
{ {
snprintf (line, DIM(line)-1, "SETKEYDESC %s", desc); snprintf (line, DIM(line), "SETKEYDESC %s", desc);
err = assuan_transact (agent_ctx, line, err = assuan_transact (agent_ctx, line,
NULL, NULL, NULL, NULL, NULL, NULL); NULL, NULL, NULL, NULL, NULL, NULL);
if (err) if (err)
return err; return err;
} }
snprintf (line, DIM(line)-1, "EXPORT_KEY %s%s%s %s", snprintf (line, DIM(line), "EXPORT_KEY %s%s%s %s",
openpgp_protected ? "--openpgp ":"", openpgp_protected ? "--openpgp ":"",
cache_nonce_addr && *cache_nonce_addr? "--cache-nonce=":"", cache_nonce_addr && *cache_nonce_addr? "--cache-nonce=":"",
cache_nonce_addr && *cache_nonce_addr? *cache_nonce_addr:"", cache_nonce_addr && *cache_nonce_addr? *cache_nonce_addr:"",
@ -2241,14 +2226,14 @@ agent_delete_key (ctrl_t ctrl, const char *hexkeygrip, const char *desc,
if (desc) if (desc)
{ {
snprintf (line, DIM(line)-1, "SETKEYDESC %s", desc); snprintf (line, DIM(line), "SETKEYDESC %s", desc);
err = assuan_transact (agent_ctx, line, err = assuan_transact (agent_ctx, line,
NULL, NULL, NULL, NULL, NULL, NULL); NULL, NULL, NULL, NULL, NULL, NULL);
if (err) if (err)
return err; return err;
} }
snprintf (line, DIM(line)-1, "DELETE_KEY%s %s", snprintf (line, DIM(line), "DELETE_KEY%s %s",
force? " --force":"", hexkeygrip); force? " --force":"", hexkeygrip);
err = assuan_transact (agent_ctx, line, NULL, NULL, err = assuan_transact (agent_ctx, line, NULL, NULL,
default_inq_cb, &dfltparm, default_inq_cb, &dfltparm,
@ -2287,7 +2272,7 @@ agent_passwd (ctrl_t ctrl, const char *hexkeygrip, const char *desc, int verify,
if (desc) if (desc)
{ {
snprintf (line, DIM(line)-1, "SETKEYDESC %s", desc); snprintf (line, DIM(line), "SETKEYDESC %s", desc);
err = assuan_transact (agent_ctx, line, err = assuan_transact (agent_ctx, line,
NULL, NULL, NULL, NULL, NULL, NULL); NULL, NULL, NULL, NULL, NULL, NULL);
if (err) if (err)
@ -2295,12 +2280,12 @@ agent_passwd (ctrl_t ctrl, const char *hexkeygrip, const char *desc, int verify,
} }
if (verify) if (verify)
snprintf (line, DIM(line)-1, "PASSWD %s%s --verify %s", snprintf (line, DIM(line), "PASSWD %s%s --verify %s",
cache_nonce_addr && *cache_nonce_addr? "--cache-nonce=":"", cache_nonce_addr && *cache_nonce_addr? "--cache-nonce=":"",
cache_nonce_addr && *cache_nonce_addr? *cache_nonce_addr:"", cache_nonce_addr && *cache_nonce_addr? *cache_nonce_addr:"",
hexkeygrip); hexkeygrip);
else else
snprintf (line, DIM(line)-1, "PASSWD %s%s %s%s %s", snprintf (line, DIM(line), "PASSWD %s%s %s%s %s",
cache_nonce_addr && *cache_nonce_addr? "--cache-nonce=":"", cache_nonce_addr && *cache_nonce_addr? "--cache-nonce=":"",
cache_nonce_addr && *cache_nonce_addr? *cache_nonce_addr:"", cache_nonce_addr && *cache_nonce_addr? *cache_nonce_addr:"",
passwd_nonce_addr && *passwd_nonce_addr? "--passwd-nonce=":"", passwd_nonce_addr && *passwd_nonce_addr? "--passwd-nonce=":"",

View File

@ -53,9 +53,9 @@ progress_cb (void *ctx, const char *what, int printchar,
(void)ctx; (void)ctx;
if ( printchar == '\n' && !strcmp (what, "primegen") ) if ( printchar == '\n' && !strcmp (what, "primegen") )
snprintf (buf, sizeof buf -1, "%.20s X 100 100", what ); snprintf (buf, sizeof buf, "%.20s X 100 100", what );
else else
snprintf (buf, sizeof buf -1, "%.20s %c %d %d", snprintf (buf, sizeof buf, "%.20s %c %d %d",
what, printchar=='\n'?'X':printchar, current, total ); what, printchar=='\n'?'X':printchar, current, total );
write_status_text (STATUS_PROGRESS, buf); write_status_text (STATUS_PROGRESS, buf);
} }
@ -356,7 +356,7 @@ write_status_begin_signing (gcry_md_hd_t md)
ga = map_md_openpgp_to_gcry (i); ga = map_md_openpgp_to_gcry (i);
if (ga && gcry_md_is_enabled (md, ga) && buflen+10 < DIM(buf)) if (ga && gcry_md_is_enabled (md, ga) && buflen+10 < DIM(buf))
{ {
snprintf (buf+buflen, DIM(buf) - buflen - 1, snprintf (buf+buflen, DIM(buf) - buflen,
"%sH%d", buflen? " ":"",i); "%sH%d", buflen? " ":"",i);
buflen += strlen (buf+buflen); buflen += strlen (buf+buflen);
} }

View File

@ -4877,7 +4877,6 @@ gen_card_key (int algo, int keyno, int is_primary, kbnode_t pub_root,
gcry_sexp_t s_key; gcry_sexp_t s_key;
snprintf (keyid, DIM(keyid), "OPENPGP.%d", keyno); snprintf (keyid, DIM(keyid), "OPENPGP.%d", keyno);
keyid[DIM(keyid)-1] = 0;
if (algo != PUBKEY_ALGO_RSA) if (algo != PUBKEY_ALGO_RSA)
return gpg_error (GPG_ERR_PUBKEY_ALGO); return gpg_error (GPG_ERR_PUBKEY_ALGO);

View File

@ -148,9 +148,9 @@ ask_outfile_name( const char *name, size_t namelen )
n = strlen(s) + (defname?strlen (defname):0) + 10; n = strlen(s) + (defname?strlen (defname):0) + 10;
prompt = xmalloc (n); prompt = xmalloc (n);
if (defname) if (defname)
snprintf (prompt, n-1, "%s [%s]: ", s, defname ); snprintf (prompt, n, "%s [%s]: ", s, defname );
else else
snprintf (prompt, n-1, "%s: ", s ); snprintf (prompt, n, "%s: ", s );
tty_enable_completion(NULL); tty_enable_completion(NULL);
fname = cpr_get ("openfile.askoutname", prompt ); fname = cpr_get ("openfile.askoutname", prompt );
cpr_kill_prompt (); cpr_kill_prompt ();

View File

@ -347,7 +347,7 @@ passphrase_to_dek (int cipher_algo, STRING2KEY *s2k,
{ {
char buf[50]; char buf[50];
snprintf (buf, sizeof buf -1, "%d %d %d", snprintf (buf, sizeof buf, "%d %d %d",
cipher_algo, s2k->mode, s2k->hash_algo ); cipher_algo, s2k->mode, s2k->hash_algo );
write_status_text ( STATUS_NEED_PASSPHRASE_SYM, buf ); write_status_text ( STATUS_NEED_PASSPHRASE_SYM, buf );
} }
@ -447,7 +447,7 @@ emit_status_need_passphrase (u32 *keyid, u32 *mainkeyid, int pubkey_algo)
write_status_text (STATUS_USERID_HINT, us); write_status_text (STATUS_USERID_HINT, us);
xfree (us); xfree (us);
snprintf (buf, sizeof buf -1, "%08lX%08lX %08lX%08lX %d 0", snprintf (buf, sizeof buf, "%08lX%08lX %08lX%08lX %d 0",
(ulong)keyid[0], (ulong)keyid[0],
(ulong)keyid[1], (ulong)keyid[1],
(ulong)(mainkeyid? mainkeyid[0]:keyid[0]), (ulong)(mainkeyid? mainkeyid[0]:keyid[0]),

View File

@ -1872,7 +1872,7 @@ verify_a_chv (app_t app,
prompt_buffer = xtrymalloc (promptsize); prompt_buffer = xtrymalloc (promptsize);
if (!prompt_buffer) if (!prompt_buffer)
return gpg_error_from_syserror (); return gpg_error_from_syserror ();
snprintf (prompt_buffer, promptsize-1, PROMPTSTRING, sigcount); snprintf (prompt_buffer, promptsize, PROMPTSTRING, sigcount);
prompt = prompt_buffer; prompt = prompt_buffer;
#undef PROMPTSTRING #undef PROMPTSTRING
} }

View File

@ -1292,8 +1292,7 @@ handle_connections (int listen_fd)
char threadname[50]; char threadname[50];
npth_t thread; npth_t thread;
snprintf (threadname, sizeof threadname-1, "conn fd=%d", fd); snprintf (threadname, sizeof threadname, "conn fd=%d", fd);
threadname[sizeof threadname -1] = 0;
ctrl->thread_startup.fd = INT2FD (fd); ctrl->thread_startup.fd = INT2FD (fd);
ret = npth_create (&thread, &tattr, start_connection_thread, ctrl); ret = npth_create (&thread, &tattr, start_connection_thread, ctrl);
if (ret) if (ret)

View File

@ -243,16 +243,14 @@ gpgsm_agent_pksign (ctrl_t ctrl, const char *keygrip, const char *desc,
if (rc) if (rc)
return rc; return rc;
snprintf (line, DIM(line)-1, "SIGKEY %s", keygrip); snprintf (line, DIM(line), "SIGKEY %s", keygrip);
line[DIM(line)-1] = 0;
rc = assuan_transact (agent_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL); rc = assuan_transact (agent_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
if (rc) if (rc)
return rc; return rc;
if (desc) if (desc)
{ {
snprintf (line, DIM(line)-1, "SETKEYDESC %s", desc); snprintf (line, DIM(line), "SETKEYDESC %s", desc);
line[DIM(line)-1] = 0;
rc = assuan_transact (agent_ctx, line, rc = assuan_transact (agent_ctx, line,
NULL, NULL, NULL, NULL, NULL, NULL); NULL, NULL, NULL, NULL, NULL, NULL);
if (rc) if (rc)
@ -335,8 +333,7 @@ gpgsm_scd_pksign (ctrl_t ctrl, const char *keyid, const char *desc,
init_membuf (&data, 1024); init_membuf (&data, 1024);
snprintf (line, DIM(line)-1, "SCD PKSIGN %s %s", hashopt, keyid); snprintf (line, DIM(line), "SCD PKSIGN %s %s", hashopt, keyid);
line[DIM(line)-1] = 0;
rc = assuan_transact (agent_ctx, line, rc = assuan_transact (agent_ctx, line,
put_membuf_cb, &data, default_inq_cb, &inq_parm, put_membuf_cb, &data, default_inq_cb, &inq_parm,
NULL, NULL); NULL, NULL);
@ -429,16 +426,14 @@ gpgsm_agent_pkdecrypt (ctrl_t ctrl, const char *keygrip, const char *desc,
return rc; return rc;
assert ( DIM(line) >= 50 ); assert ( DIM(line) >= 50 );
snprintf (line, DIM(line)-1, "SETKEY %s", keygrip); snprintf (line, DIM(line), "SETKEY %s", keygrip);
line[DIM(line)-1] = 0;
rc = assuan_transact (agent_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL); rc = assuan_transact (agent_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
if (rc) if (rc)
return rc; return rc;
if (desc) if (desc)
{ {
snprintf (line, DIM(line)-1, "SETKEYDESC %s", desc); snprintf (line, DIM(line), "SETKEYDESC %s", desc);
line[DIM(line)-1] = 0;
rc = assuan_transact (agent_ctx, line, rc = assuan_transact (agent_ctx, line,
NULL, NULL, NULL, NULL, NULL, NULL); NULL, NULL, NULL, NULL, NULL, NULL);
if (rc) if (rc)
@ -594,9 +589,8 @@ gpgsm_agent_readkey (ctrl_t ctrl, int fromcard, const char *hexkeygrip,
if (rc) if (rc)
return rc; return rc;
snprintf (line, DIM(line)-1, "%sREADKEY %s", snprintf (line, DIM(line), "%sREADKEY %s",
fromcard? "SCD ":"", hexkeygrip); fromcard? "SCD ":"", hexkeygrip);
line[DIM(line)-1] = 0;
init_membuf (&data, 1024); init_membuf (&data, 1024);
rc = assuan_transact (agent_ctx, line, rc = assuan_transact (agent_ctx, line,
@ -810,8 +804,7 @@ gpgsm_agent_istrusted (ctrl_t ctrl, ksba_cert_t cert, const char *hexfpr,
if (hexfpr) if (hexfpr)
{ {
snprintf (line, DIM(line)-1, "ISTRUSTED %s", hexfpr); snprintf (line, DIM(line), "ISTRUSTED %s", hexfpr);
line[DIM(line)-1] = 0;
} }
else else
{ {
@ -824,8 +817,7 @@ gpgsm_agent_istrusted (ctrl_t ctrl, ksba_cert_t cert, const char *hexfpr,
return gpg_error (GPG_ERR_GENERAL); return gpg_error (GPG_ERR_GENERAL);
} }
snprintf (line, DIM(line)-1, "ISTRUSTED %s", fpr); snprintf (line, DIM(line), "ISTRUSTED %s", fpr);
line[DIM(line)-1] = 0;
xfree (fpr); xfree (fpr);
} }
@ -868,8 +860,7 @@ gpgsm_agent_marktrusted (ctrl_t ctrl, ksba_cert_t cert)
xfree (dn); xfree (dn);
if (!dnfmt) if (!dnfmt)
return gpg_error_from_syserror (); return gpg_error_from_syserror ();
snprintf (line, DIM(line)-1, "MARKTRUSTED %s S %s", fpr, dnfmt); snprintf (line, DIM(line), "MARKTRUSTED %s S %s", fpr, dnfmt);
line[DIM(line)-1] = 0;
ksba_free (dnfmt); ksba_free (dnfmt);
xfree (fpr); xfree (fpr);
@ -895,8 +886,7 @@ gpgsm_agent_havekey (ctrl_t ctrl, const char *hexkeygrip)
if (!hexkeygrip || strlen (hexkeygrip) != 40) if (!hexkeygrip || strlen (hexkeygrip) != 40)
return gpg_error (GPG_ERR_INV_VALUE); return gpg_error (GPG_ERR_INV_VALUE);
snprintf (line, DIM(line)-1, "HAVEKEY %s", hexkeygrip); snprintf (line, DIM(line), "HAVEKEY %s", hexkeygrip);
line[DIM(line)-1] = 0;
rc = assuan_transact (agent_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL); rc = assuan_transact (agent_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
return rc; return rc;
@ -1045,16 +1035,14 @@ gpgsm_agent_passwd (ctrl_t ctrl, const char *hexkeygrip, const char *desc)
if (desc) if (desc)
{ {
snprintf (line, DIM(line)-1, "SETKEYDESC %s", desc); snprintf (line, DIM(line), "SETKEYDESC %s", desc);
line[DIM(line)-1] = 0;
rc = assuan_transact (agent_ctx, line, rc = assuan_transact (agent_ctx, line,
NULL, NULL, NULL, NULL, NULL, NULL); NULL, NULL, NULL, NULL, NULL, NULL);
if (rc) if (rc)
return rc; return rc;
} }
snprintf (line, DIM(line)-1, "PASSWD %s", hexkeygrip); snprintf (line, DIM(line), "PASSWD %s", hexkeygrip);
line[DIM(line)-1] = 0;
rc = assuan_transact (agent_ctx, line, NULL, NULL, rc = assuan_transact (agent_ctx, line, NULL, NULL,
default_inq_cb, &inq_parm, NULL, NULL); default_inq_cb, &inq_parm, NULL, NULL);
@ -1078,8 +1066,7 @@ gpgsm_agent_get_confirmation (ctrl_t ctrl, const char *desc)
inq_parm.ctrl = ctrl; inq_parm.ctrl = ctrl;
inq_parm.ctx = agent_ctx; inq_parm.ctx = agent_ctx;
snprintf (line, DIM(line)-1, "GET_CONFIRMATION %s", desc); snprintf (line, DIM(line), "GET_CONFIRMATION %s", desc);
line[DIM(line)-1] = 0;
rc = assuan_transact (agent_ctx, line, NULL, NULL, rc = assuan_transact (agent_ctx, line, NULL, NULL,
default_inq_cb, &inq_parm, NULL, NULL); default_inq_cb, &inq_parm, NULL, NULL);
@ -1150,8 +1137,7 @@ gpgsm_agent_keyinfo (ctrl_t ctrl, const char *hexkeygrip, char **r_serialno)
if (!hexkeygrip || strlen (hexkeygrip) != 40) if (!hexkeygrip || strlen (hexkeygrip) != 40)
return gpg_error (GPG_ERR_INV_VALUE); return gpg_error (GPG_ERR_INV_VALUE);
snprintf (line, DIM(line)-1, "KEYINFO %s", hexkeygrip); snprintf (line, DIM(line), "KEYINFO %s", hexkeygrip);
line[DIM(line)-1] = 0;
err = assuan_transact (agent_ctx, line, NULL, NULL, NULL, NULL, err = assuan_transact (agent_ctx, line, NULL, NULL, NULL, NULL,
keyinfo_status_cb, &serialno); keyinfo_status_cb, &serialno);
@ -1196,7 +1182,7 @@ gpgsm_agent_ask_passphrase (ctrl_t ctrl, const char *desc_msg, int repeat,
if (desc_msg && *desc_msg && !(arg4 = percent_plus_escape (desc_msg))) if (desc_msg && *desc_msg && !(arg4 = percent_plus_escape (desc_msg)))
return gpg_error_from_syserror (); return gpg_error_from_syserror ();
snprintf (line, DIM(line)-1, "GET_PASSPHRASE --data%s -- X X X %s", snprintf (line, DIM(line), "GET_PASSPHRASE --data%s -- X X X %s",
repeat? " --repeat=1 --check --qualitybar":"", repeat? " --repeat=1 --check --qualitybar":"",
arg4); arg4);
xfree (arg4); xfree (arg4);
@ -1241,7 +1227,7 @@ gpgsm_agent_keywrap_key (ctrl_t ctrl, int forexport,
inq_parm.ctrl = ctrl; inq_parm.ctrl = ctrl;
inq_parm.ctx = agent_ctx; inq_parm.ctx = agent_ctx;
snprintf (line, DIM(line)-1, "KEYWRAP_KEY %s", snprintf (line, DIM(line), "KEYWRAP_KEY %s",
forexport? "--export":"--import"); forexport? "--export":"--import");
init_membuf_secure (&data, 64); init_membuf_secure (&data, 64);
@ -1335,14 +1321,14 @@ gpgsm_agent_export_key (ctrl_t ctrl, const char *keygrip, const char *desc,
if (desc) if (desc)
{ {
snprintf (line, DIM(line)-1, "SETKEYDESC %s", desc); snprintf (line, DIM(line), "SETKEYDESC %s", desc);
err = assuan_transact (agent_ctx, line, err = assuan_transact (agent_ctx, line,
NULL, NULL, NULL, NULL, NULL, NULL); NULL, NULL, NULL, NULL, NULL, NULL);
if (err) if (err)
return err; return err;
} }
snprintf (line, DIM(line)-1, "EXPORT_KEY %s", keygrip); snprintf (line, DIM(line), "EXPORT_KEY %s", keygrip);
init_membuf_secure (&data, 1024); init_membuf_secure (&data, 1024);
err = assuan_transact (agent_ctx, line, err = assuan_transact (agent_ctx, line,

View File

@ -215,9 +215,8 @@ prepare_dirmngr (ctrl_t ctrl, assuan_context_t ctx, gpg_error_t err)
char *pass = server->pass ? server->pass : ""; char *pass = server->pass ? server->pass : "";
char *base = server->base ? server->base : ""; char *base = server->base ? server->base : "";
snprintf (line, DIM (line) - 1, "LDAPSERVER %s:%i:%s:%s:%s", snprintf (line, DIM (line), "LDAPSERVER %s:%i:%s:%s:%s",
server->host, server->port, user, pass, base); server->host, server->port, user, pass, base);
line[DIM (line) - 1] = 0;
assuan_transact (ctx, line, NULL, NULL, NULL, NULL, NULL, NULL); assuan_transact (ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
/* The code below is not required because we don't return an error. */ /* The code below is not required because we don't return an error. */
@ -548,10 +547,9 @@ gpgsm_dirmngr_isvalid (ctrl_t ctrl,
NULL, NULL, NULL, NULL, NULL, NULL); NULL, NULL, NULL, NULL, NULL, NULL);
did_options = 1; did_options = 1;
} }
snprintf (line, DIM(line)-1, "ISVALID%s %s", snprintf (line, DIM(line), "ISVALID%s %s",
use_ocsp == 2? " --only-ocsp --force-default-responder":"", use_ocsp == 2? " --only-ocsp --force-default-responder":"",
certid); certid);
line[DIM(line)-1] = 0;
xfree (certid); xfree (certid);
rc = assuan_transact (dirmngr_ctx, line, NULL, NULL, rc = assuan_transact (dirmngr_ctx, line, NULL, NULL,
@ -803,9 +801,8 @@ gpgsm_dirmngr_lookup (ctrl_t ctrl, strlist_t names, int cache_only,
return out_of_core (); return out_of_core ();
} }
snprintf (line, DIM(line)-1, "LOOKUP%s %s", snprintf (line, DIM(line), "LOOKUP%s %s",
cache_only? " --cache-only":"", pattern); cache_only? " --cache-only":"", pattern);
line[DIM(line)-1] = 0;
xfree (pattern); xfree (pattern);
parm.ctrl = ctrl; parm.ctrl = ctrl;
@ -861,7 +858,7 @@ get_cached_cert (assuan_context_t ctx,
*r_cert = NULL; *r_cert = NULL;
bin2hex (fpr, 20, hexfpr); bin2hex (fpr, 20, hexfpr);
snprintf (line, DIM(line)-1, "LOOKUP --single --cache-only 0x%s", hexfpr); snprintf (line, DIM(line), "LOOKUP --single --cache-only 0x%s", hexfpr);
init_membuf (&mb, 4096); init_membuf (&mb, 4096);
err = assuan_transact (ctx, line, get_cached_cert_data_cb, &mb, err = assuan_transact (ctx, line, get_cached_cert_data_cb, &mb,

View File

@ -719,7 +719,7 @@ proc_parameters (ctrl_t ctrl, struct para_data_s *para,
else if (!outctrl->dryrun) /* Generate new key. */ else if (!outctrl->dryrun) /* Generate new key. */
{ {
sprintf (numbuf, "%u", nbits); sprintf (numbuf, "%u", nbits);
snprintf ((char*)keyparms, DIM (keyparms)-1, snprintf ((char*)keyparms, DIM (keyparms),
"(6:genkey(3:rsa(5:nbits%d:%s)))", "(6:genkey(3:rsa(5:nbits%d:%s)))",
(int)strlen (numbuf), numbuf); (int)strlen (numbuf), numbuf);
rc = gpgsm_agent_genkey (ctrl, keyparms, &public); rc = gpgsm_agent_genkey (ctrl, keyparms, &public);