Fix leak in SSL_set_tlsext_status_ocsp_resp#28894
Fix leak in SSL_set_tlsext_status_ocsp_resp#28894rgacogne wants to merge 1 commit intoopenssl:masterfrom
SSL_set_tlsext_status_ocsp_resp#28894Conversation
|
I see some tests are failing, so clearly this is not as straight-forward as it seemed in my own case. I'll look into it. |
The tests are failing because the test case was incorrectly changed in b1b4b15#diff-ac041dcce48346a57d70403803133a58fb4ac5764e173d7cbfd6db2c2df5afdcR1943 This free call should be removed. |
ssl/s3_lib.c
Outdated
|
|
||
| OPENSSL_free(parg); |
There was a problem hiding this comment.
I think this would be a better (more backwards compatible with pre-3.6 versions) fix.
| OPENSSL_free(parg); | |
| sc->ext.ocsp.resp = parg; | |
| sc->ext.ocsp.resp_len = larg; |
There was a problem hiding this comment.
This is fine by me, but is it OK to have both sc->ext.ocsp.resp and sc->ext.ocsp.resp_ex set? The current code seems to try hard to avoid ending up in that situation, although it's not clear to me whether resp is still actually used.
There was a problem hiding this comment.
Done. I successfully tested the change locally.
The changes introduced in b1b4b15 cause the `resp` parameter to no longer be assigned to the `SSL` object. Since it is not freed either, and the caller used to expect that, the memory is now leaked. This commit assigns the value to the `SSL` object. There is an early error return when `sk_OCSP_RESPONSE_new_reserve` fails where the memory is not freed. I'm not sure whether it makes sense to free the memory in that case, as the documentation does not mention anything. Fixes openssl#28888 CLA: trivial Signed-off-by: Remi Gacogne <[email protected]>
Sashan
left a comment
There was a problem hiding this comment.
I agree with CLA trivial.
thank you for the fix.
|
Ping @t8m for a confirmation |
|
This PR is in a state where it requires action by @openssl/committers but the last update was 30 days ago |
Fixes openssl#28888 Fixes b1b4b15 Instead of transferring the ownership of the single OCSP response to the SSL object, the multi-stapling PR modified the semantics of SSL_set_tlsext_status_ocsp_resp() to copying semantics. This change reverts the behavior to the previous one. Partially based on fix by Remi Gacogne: openssl#28894
|
I took over this fix in PR #29251 |
Fixes #28888 Fixes b1b4b15 Instead of transferring the ownership of the single OCSP response to the SSL object, the multi-stapling PR modified the semantics of SSL_set_tlsext_status_ocsp_resp() to copying semantics. This change reverts the behavior to the previous one. Partially based on fix by Remi Gacogne: #28894 Reviewed-by: Matt Caswell <[email protected]> Reviewed-by: Saša Nedvědický <[email protected]> (Merged from #29251)
Fixes #28888 Fixes b1b4b15 Instead of transferring the ownership of the single OCSP response to the SSL object, the multi-stapling PR modified the semantics of SSL_set_tlsext_status_ocsp_resp() to copying semantics. This change reverts the behavior to the previous one. Partially based on fix by Remi Gacogne: #28894 Reviewed-by: Matt Caswell <[email protected]> Reviewed-by: Saša Nedvědický <[email protected]> (Merged from #29251) (cherry picked from commit 7e50e03)
Fixes openssl#28888 Fixes b1b4b15 Instead of transferring the ownership of the single OCSP response to the SSL object, the multi-stapling PR modified the semantics of SSL_set_tlsext_status_ocsp_resp() to copying semantics. This change reverts the behavior to the previous one. Partially based on fix by Remi Gacogne: openssl#28894 Reviewed-by: Matt Caswell <[email protected]> Reviewed-by: Saša Nedvědický <[email protected]> (Merged from openssl#29251)
The changes introduced in b1b4b15 cause the
respparameter to no longer be assigned to theSSLobject.Since it is not freed either, and the caller used to expect that, the memory is now leaked.
This commit frees
respright away. There is an early error return whensk_OCSP_RESPONSE_new_reservefails where the memory is not freed.I'm not sure whether it makes sense to free the memory in that case, as the documentation does not mention anything.
Fixes #28888
CLA: trivial
Checklist