diff options
| author | Michael Brown | 2025-03-31 18:44:59 +0200 |
|---|---|---|
| committer | Michael Brown | 2025-03-31 19:05:11 +0200 |
| commit | 0a48bb32145ce14b11d5d1e2a537d3d567489385 (patch) | |
| tree | c40acc641986801e9b1725879ef0fb0b561f71a1 /src/net | |
| parent | [tls] Support fragmentation of transmitted records (diff) | |
| download | ipxe-0a48bb32145ce14b11d5d1e2a537d3d567489385.tar.gz ipxe-0a48bb32145ce14b11d5d1e2a537d3d567489385.tar.xz ipxe-0a48bb32145ce14b11d5d1e2a537d3d567489385.zip | |
[x509] Ensure certificate remains valid during x509_append()
The allocation of memory for the certificate chain link may cause the
certificate itself to be freed by the cache discarder, if the only
current reference to the certificate is held by the certificate store
and the system runs out of memory during the call to malloc().
Ensure that this cannot happen by taking out a temporary additional
reference to the certificate within x509_append(), rather than
requiring the caller to do so.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/net')
| -rw-r--r-- | src/net/tls.c | 7 |
1 files changed, 0 insertions, 7 deletions
diff --git a/src/net/tls.c b/src/net/tls.c index 4c135f090..643b9292d 100644 --- a/src/net/tls.c +++ b/src/net/tls.c @@ -2470,9 +2470,6 @@ static int tls_new_certificate_request ( struct tls_connection *tls, /* Determine client certificate to be sent, if any */ cert = x509_find_key ( NULL, tls->client.key ); if ( cert ) { - - /* Get temporary reference to certificate */ - x509_get ( cert ); DBGC ( tls, "TLS %p selected client certificate %s\n", tls, x509_name ( cert ) ); @@ -2491,14 +2488,10 @@ static int tls_new_certificate_request ( struct tls_connection *tls, "to private key\n", tls ); } - /* Drop local reference (if any) to client certificate */ - x509_put ( cert ); - return 0; err_auto_append: err_append: - x509_put ( cert ); x509_chain_put ( tls->client.chain ); tls->client.chain = NULL; err_alloc: |
