mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +01:00
gpg: Fix memory leak in the error case of signature creation.
* g10/sign.c (write_signature_packets): Free SIG. Also replace xcalloc by xtrycalloc. -- If do_sign fails SIG was not released. Note that in the good case SIG is transferred to PKT and freed by free_packet. Reported-by: Stephan Müller Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
8810314e37
commit
5996c7bf99
11
g10/sign.c
11
g10/sign.c
@ -686,7 +686,10 @@ write_signature_packets (SK_LIST sk_list, IOBUF out, gcry_md_hd_t hash,
|
|||||||
pk = sk_rover->pk;
|
pk = sk_rover->pk;
|
||||||
|
|
||||||
/* Build the signature packet. */
|
/* Build the signature packet. */
|
||||||
sig = xmalloc_clear (sizeof *sig);
|
sig = xtrycalloc (1, sizeof *sig);
|
||||||
|
if (!sig)
|
||||||
|
return gpg_error_from_syserror ();
|
||||||
|
|
||||||
if (duration || opt.sig_policy_url
|
if (duration || opt.sig_policy_url
|
||||||
|| opt.sig_notations || opt.sig_keyserver_url)
|
|| opt.sig_notations || opt.sig_keyserver_url)
|
||||||
sig->version = 4;
|
sig->version = 4;
|
||||||
@ -731,8 +734,12 @@ write_signature_packets (SK_LIST sk_list, IOBUF out, gcry_md_hd_t hash,
|
|||||||
print_status_sig_created (pk, sig, status_letter);
|
print_status_sig_created (pk, sig, status_letter);
|
||||||
free_packet (&pkt);
|
free_packet (&pkt);
|
||||||
if (rc)
|
if (rc)
|
||||||
log_error ("build signature packet failed: %s\n", gpg_strerror (rc));
|
log_error ("build signature packet failed: %s\n",
|
||||||
|
gpg_strerror (rc));
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
xfree (sig);
|
||||||
|
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user