Commit 04c9fa4
committed
phar: free EVP_PKEY on EVP_MD_CTX_create/EVP_VerifyInit failure in phar_verify_signature
In phar_verify_signature, PEM_read_bio_PUBKEY allocates EVP_PKEY *key. When EVP_MD_CTX_create() returns NULL or EVP_VerifyInit() fails, the early return freed md_ctx but not key, leaking the object in OpenSSL's heap.
The existing failure: label already calls both EVP_PKEY_free and EVP_MD_CTX_destroy. This adds EVP_PKEY_free(key) to the earlier exit branch, mirroring the symmetric fix in phar_create_signature from GH-19563 (f5a3a64).
ASAN catches the leak when EVP_VerifyInit fails, typically in FIPS-mode deployments with SHA-1 disabled.1 parent f7eb5ef commit 04c9fa4
2 files changed
Lines changed: 35 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1640 | 1640 | | |
1641 | 1641 | | |
1642 | 1642 | | |
| 1643 | + | |
1643 | 1644 | | |
1644 | 1645 | | |
1645 | 1646 | | |
| |||
0 commit comments