mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
Assorted memory leak fixes on the error code paths.
-- These are taken from these commits: 98c52ae * card: Intialize pointer to avoid double free fc5fac8 * kbx: Avoid uninitialized read fa0771f * g10: Avoid memory leaks 25aa353 * dirmgr: Avoid double free 33a2362 * agent: Fix memory leaks e6132bc * sm: Avoid memory leaks and double double-free 2af7bb2 * g10: Fix memory leaks 0d2c1e9 * dirmgr: clean up memory on error code paths GnuPG-bug-id: 5393 Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
9d63ba2721
commit
b677e2ec98
@ -381,7 +381,7 @@ agent_ask_new_passphrase (ctrl_t ctrl, const char *prompt,
|
||||
if (!pi2)
|
||||
{
|
||||
err = gpg_error_from_syserror ();
|
||||
xfree (pi2);
|
||||
xfree (pi);
|
||||
return err;
|
||||
}
|
||||
pi->max_length = MAX_PASSPHRASE_LEN + 1;
|
||||
|
@ -206,7 +206,7 @@ keygripstr_from_pk_file (app_t app, int fid, char *r_gripstr)
|
||||
|
||||
newlen = 1 + buflen[i] - offset[i];
|
||||
newbuf = xtrymalloc (newlen);
|
||||
if (!newlen)
|
||||
if (!newbuf)
|
||||
{
|
||||
xfree (buffer[0]);
|
||||
xfree (buffer[1]);
|
||||
|
@ -293,7 +293,6 @@ extract_pss_params (gcry_sexp_t s_sig, int *r_algo, unsigned int *r_saltlen)
|
||||
if (*r_saltlen < 20)
|
||||
{
|
||||
log_error ("length of PSS salt too short\n");
|
||||
gcry_sexp_release (s_sig);
|
||||
return gpg_error (GPG_ERR_DIGEST_ALGO);
|
||||
}
|
||||
if (!*r_algo)
|
||||
|
@ -203,6 +203,7 @@ encrypt_dek (const DEK dek, ksba_cert_t cert, unsigned char **encval)
|
||||
rc = encode_session_key (dek, &s_data);
|
||||
if (rc)
|
||||
{
|
||||
gcry_sexp_release (s_pkey);
|
||||
log_error ("encode_session_key failed: %s\n", gpg_strerror (rc));
|
||||
return rc;
|
||||
}
|
||||
|
25
sm/server.c
25
sm/server.c
@ -724,8 +724,13 @@ cmd_export (assuan_context_t ctx, char *line)
|
||||
|
||||
if (opt_secret)
|
||||
{
|
||||
if (!list || !*list->d)
|
||||
if (!list)
|
||||
return set_error (GPG_ERR_NO_DATA, "No key given");
|
||||
if (!*list->d)
|
||||
{
|
||||
free_strlist (list);
|
||||
return set_error (GPG_ERR_NO_DATA, "No key given");
|
||||
}
|
||||
if (list->next)
|
||||
return set_error (GPG_ERR_TOO_MANY, "Only one key allowed");
|
||||
}
|
||||
@ -948,17 +953,27 @@ do_listkeys (assuan_context_t ctx, char *line, int mode)
|
||||
int outfd = translate_sys2libc_fd (assuan_get_output_fd (ctx), 1);
|
||||
|
||||
if ( outfd == -1 )
|
||||
return set_error (GPG_ERR_ASS_NO_OUTPUT, NULL);
|
||||
{
|
||||
free_strlist (list);
|
||||
return set_error (GPG_ERR_ASS_NO_OUTPUT, NULL);
|
||||
}
|
||||
fp = es_fdopen_nc (outfd, "w");
|
||||
if (!fp)
|
||||
return set_error (gpg_err_code_from_syserror (), "es_fdopen() failed");
|
||||
{
|
||||
free_strlist (list);
|
||||
return set_error (gpg_err_code_from_syserror (),
|
||||
"es_fdopen() failed");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fp = es_fopencookie (ctx, "w", data_line_cookie_functions);
|
||||
if (!fp)
|
||||
return set_error (GPG_ERR_ASS_GENERAL,
|
||||
"error setting up a data stream");
|
||||
{
|
||||
free_strlist (list);
|
||||
return set_error (GPG_ERR_ASS_GENERAL,
|
||||
"error setting up a data stream");
|
||||
}
|
||||
}
|
||||
|
||||
ctrl->with_colons = 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user