mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-03-03 07:29:23 +00:00
Fix redbean certificate free error
This fixes a regression from a change a few weeks ago in git commit
af645fcbec
which caused certificates to
not be free()'d correctly if the certificates are chained. dlmalloc()
should have printed an error in most build modes. ASAN caught it too.
This commit is contained in:
parent
f59b5dbd7c
commit
c13142dad2
2 changed files with 9 additions and 2 deletions
|
@ -203,7 +203,8 @@ o/$(MODE)/tool/net/redbean-demo.com: \
|
|||
-o o/$(MODE)/tool/net/.redbean-demo/.symtab $<
|
||||
@$(COMPILE) -AZIP -T$@ o/$(MODE)/third_party/infozip/zip.com -9qj $@ \
|
||||
o/$(MODE)/tool/net/.redbean-demo/.ape \
|
||||
o/$(MODE)/tool/net/.redbean-demo/.symtab
|
||||
o/$(MODE)/tool/net/.redbean-demo/.symtab \
|
||||
tool/net/help.txt
|
||||
|
||||
# REDBEAN-STATIC.COM
|
||||
#
|
||||
|
|
|
@ -1434,7 +1434,7 @@ static void WipeSigningKeys(void) {
|
|||
if (!certs.p[i].cert) continue;
|
||||
if (!certs.p[i].cert->ca_istrue) continue;
|
||||
mbedtls_pk_free(certs.p[i].key);
|
||||
certs.p[i].key = 0;
|
||||
Free(&certs.p[i].key);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1451,6 +1451,12 @@ static void PsksDestroy(void) {
|
|||
|
||||
static void CertsDestroy(void) {
|
||||
size_t i;
|
||||
// break up certificate chains to prevent double free
|
||||
for (i = 0; i < certs.n; ++i) {
|
||||
if (certs.p[i].cert) {
|
||||
certs.p[i].cert->next = 0;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < certs.n; ++i) {
|
||||
mbedtls_x509_crt_free(certs.p[i].cert);
|
||||
free(certs.p[i].cert);
|
||||
|
|
Loading…
Add table
Reference in a new issue