mirror of
git://git.gnupg.org/gnupg.git
synced 2025-05-19 09:02:22 +02:00
scd: Fix memory leak in command READKEY.
* scd/command.c (cmd_readcert): Replace xstrdup by xtrystrdup. (cmd_readkey): Ditto. Fix memory leak. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
0e48aa0849
commit
2b843be5ac
@ -2046,7 +2046,6 @@ app_do_with_keygrip (ctrl_t ctrl, int action, const char *keygrip_str,
|
|||||||
int capability)
|
int capability)
|
||||||
{
|
{
|
||||||
int locked = 0;
|
int locked = 0;
|
||||||
gpg_error_t err;
|
|
||||||
card_t c;
|
card_t c;
|
||||||
app_t a, a_prev;
|
app_t a, a_prev;
|
||||||
|
|
||||||
|
@ -519,7 +519,10 @@ cmd_readcert (assuan_context_t ctx, char *line)
|
|||||||
if ((rc = open_card (ctrl)))
|
if ((rc = open_card (ctrl)))
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
line = xstrdup (line); /* Need a copy of the line. */
|
line = xtrystrdup (line); /* Need a copy of the line. */
|
||||||
|
if (!line)
|
||||||
|
return gpg_error_from_syserror ();
|
||||||
|
|
||||||
rc = app_readcert (ctrl->card_ctx, ctrl, line, &cert, &ncert);
|
rc = app_readcert (ctrl->card_ctx, ctrl, line, &cert, &ncert);
|
||||||
if (rc)
|
if (rc)
|
||||||
log_error ("app_readcert failed: %s\n", gpg_strerror (rc));
|
log_error ("app_readcert failed: %s\n", gpg_strerror (rc));
|
||||||
@ -634,7 +637,10 @@ cmd_readkey (assuan_context_t ctx, char *line)
|
|||||||
opt_info = opt_nokey = 1;
|
opt_info = opt_nokey = 1;
|
||||||
|
|
||||||
line = skip_options (line);
|
line = skip_options (line);
|
||||||
line = xstrdup (line); /* Need a copy of the line. */
|
|
||||||
|
line = xtrystrdup (line); /* Need a copy of the line. */
|
||||||
|
if (!line)
|
||||||
|
return gpg_error_from_syserror ();
|
||||||
|
|
||||||
if (strlen (line) == 40)
|
if (strlen (line) == 40)
|
||||||
{
|
{
|
||||||
@ -689,6 +695,7 @@ cmd_readkey (assuan_context_t ctx, char *line)
|
|||||||
|
|
||||||
leave:
|
leave:
|
||||||
xfree (pk);
|
xfree (pk);
|
||||||
|
xfree (line);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user