feat(libSceLibreSsl): release OCSP response ownership #12850
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12850"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-10-29T12:37:06Z.
What
Implement
OCSP_RESPONSE_free, including optional response bytes, nested ASN.1 strings, dynamic OID names/data/containers, static OIDs and NDEF borrowed data. Owned string/OID bytes are cleared before release. Members are released in reverse ASN.1 sequence order through the application allocator.The layouts and ownership rules follow LibreSSL 2.5.4, specifically
ocsp/ocsp.h,ocsp/ocsp_asn.c,asn1/tasn_fre.c,asn1/asn1_lib.candasn1/a_object.c. Negative lengths for owned non-null data throw before any member is freed. Console/allocator interoperability remains unverified and is recorded in debt.The overlap checker reports shared library header/CMake/debt contexts. No inspected open PR implements this export; this change does not depend on the pending OCSP accessor work.
Tested
Windows 11, MinGW-w64 GCC 16.1, Release full-runtime CMake configuration. Built
guest_libressl_ocsp_response_ownership_tests. CTest passedguest_libressl_ocsp_response_ownership,guest_libressl_x509_errors,guest_libressl_asn1andguest_libressl3_key_reference.The new recording-allocator test checks full nested release order, clearing before release, null members, static/dynamic OID flags, NDEF borrowed data and rejection of a negative owned length without partial destruction. Public-header audit passed: 373 libraries / 13,938 exports. Conventions checked against origin/main and upstream/main.
A separate locally built LibreSSL 2.5.4 native probe confirmed the 16-byte OCSP response layout and preservation of static OID / NDEF borrowed data, including a negative borrowed length. No title or console execution was performed.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-29T12:41:30Z.
Review: APPROVED
Reviewed — approved
OCSP_RESPONSE_freefrees the same members, in the same order, as LibreSSL 2.5.4'sASN1_item_free/ASN1_STRING_free/ASN1_OBJECT_free. The new test passes and fails under every mutation I tried.What I ran
59912e5595f9700cd005e612e4deaaded7f869dcmain:5454cd2e455994d992aca39335ce60507eeda1ebBUILD_TESTING=ON, in a clean worktree with the PR merged intomain(--no-ff, no conflicts).Results
maingit diff --checkcheck_conventions.py --base origin/mainAll conventions checks passed.libs+ all 27 libressl test targetsctest -R guest_libressl(33 tests)guest_libressl_ocsp_response_ownershipT OCSP_RESPONSE_free_nid_postfixNotImplemented_nid_no_patch(__func__)count inExport.cppgoes from 299 onmainto 298ctest excerpt
I compared the implementation with the LibreSSL 2.5.4 sources at the commit the PR cites:
ocsp_asn.cL428-L452:OCSP_RESPONSEis{ENUMERATED responseStatus, [0] EXPLICIT OPTIONAL OCSP_RESPBYTES responseBytes}, andOCSP_RESPBYTESis{OBJECT responseType, OCTET STRING response}.tasn_fre.cL137-L166: a SEQUENCE frees its fields in reverse template order, then frees itself. That gives response → responseType → bytes → responseStatus → response, which is the order insrc/OcspResponseOwnership.cpp:65-71.asn1_lib.cL434-L444 (ASN1_STRING_FLAG_NDEF= 0x10) anda_object.cL372-L391 (flags 0x1/0x4/0x8):FreeStringandFreeObjectmatch these, including clearing the bytes before freeing and resettingsn/ln/data/lengthon static objects.Throwing on a negative owned length, where upstream would pass a huge
size_ttoexplicit_bzero, follows the "throw where LibreSSL faults" pattern already used in this library. The debt entry records it.Negative control
Restoring only the production files from
main(Export.cpp,include/Api.hpp, and removingsrc/OcspResponseOwnership.cpp) stops the build, because the CMake block in the same file names the source. That shows nothing about the test, so I mutatedsrc/OcspResponseOwnership.cppinstead and rebuilt the test for each mutation:what(): stub)responseTypefreed beforeresponsecheck failed at line 111)ValidateremovedASN1_OBJECT_FLAG_DYNAMICfreedAfter restoring the PR file, the test passes again.
Findings
Blocking
None.
Non-blocking
struct LibreSslOcspResponse { Asn1String* responseStatus; void* responseBytes; }toinclude/Api.hppfor the same 16-byte object. This PR addsOcspResponse/OcspResponseBytesin a new header (include/OcspResponseOwnership.hppL9-L17). The two do not conflict textually, but whichever PR lands second leaves two structs for one guest object. Suggestion: reuse one definition once the other PR merges. TheLibreSslprefix also matches neighbouring layouts such asLibreSslAsn1Object.Export.cpp(L796-L797). The new CMake block also starts after two blank lines (CMakeLists.txtL283-L284). This is cosmetic.Not verified
OCSP_RESPONSEyet.Pull request closed