Commit 1246c94
Spike
ae.net.ssl: Fix chain-cert double-free in setIdentityFromPKCS12
SSL_CTX_add_extra_chain_cert steals ownership of the X509* it receives
(does not bump refcount). The previous code called OPENSSL_sk_pop_free
on the ca stack after the add loop, freeing every element a second time.
Use OPENSSL_sk_shift to pop-and-transfer each cert one at a time. On
success the stack is empty, so the scope(exit) pop_free is a no-op. On
partial failure (add throws), remaining un-transferred certs in the stack
are freed correctly by scope(exit).1 parent b064b56 commit 1246c94
1 file changed
Lines changed: 7 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
309 | 309 | | |
310 | 310 | | |
311 | 311 | | |
312 | | - | |
| 312 | + | |
313 | 313 | | |
314 | 314 | | |
315 | 315 | | |
| |||
328 | 328 | | |
329 | 329 | | |
330 | 330 | | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
331 | 334 | | |
332 | 335 | | |
333 | 336 | | |
334 | 337 | | |
335 | 338 | | |
336 | 339 | | |
337 | | - | |
| 340 | + | |
338 | 341 | | |
339 | | - | |
| 342 | + | |
340 | 343 | | |
341 | 344 | | |
| 345 | + | |
342 | 346 | | |
343 | 347 | | |
344 | 348 | | |
| |||
0 commit comments