feat(libSceLibreSsl): implement X509_LOOKUP_file and X509_STORE_add_lookup #11105
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11105"
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 JaceTheBlu on 2026-10-25T17:41:07Z.
What
Implements
X509_LOOKUP_fileandX509_STORE_add_lookupin libSceLibreSsl, which threw and were declared without parameters, and letsX509_STORE_freefree the store's lookups. It stacks on #11100, which carries #11089.X509_LOOKUP_METHOD* X509_LOOKUP_file(void)"Load file into cache", onlyctrlset, asx509_file_lookupinby_file.cX509_LOOKUP* X509_STORE_add_lookup(X509_STORE*, X509_LOOKUP_METHOD*)methodis the given one; otherwisemallocs a 32-byte lookup asX509_LOOKUP_newleaves it (initandskip0, no method data), sets itsstore_ctxto the store and pushes it on the store's methods, doubling the element array withreallocwhennum_alloc <= num + 1assk_insertdoes; a failed push frees the new lookup and returns nullX509_STORE_freenow shuts down and frees each listed lookup asx509_lu.cdoes, instead of throwing when a lookup is listed.These follow LibreSSL 2.5.4
by_file.candx509_lu.candstack.c, which are unchanged in 2.7 (OPENBSD_6_3, whoseX509_VERIFY_PARAM_set1_hostthe module also exports). Layouts are checked withstatic_asserts on LP64.What is not modelled throws instead of being guessed: the file method's
ctrl(loading PEM certificates and CRLs needs a certificate model this module does not have yet), and thenew_item,shutdownandfreecallbacks of a guest-supplied method, which are not called. A null store, method or listed lookup throws where LibreSSL faults. The debt entry records this, and the pending-export count indocs/dev/debt/libSceLibreSsl.mddrops by two.Tested
Debian trixie container, GCC 14.2, full Release build of this branch.
ctest -R 'libressl|crypto_memcmp': all pass (18 of 18 on the stacked head), including the newguest_libressl_x509_lookup(the static method and its fields, a new lookup's fields and owner, finding a lookup again, five more methods growing the stack from 4 to 8 slots, the throwing cases) andguest_libressl_x509_lookup_allocator(onemallocper lookup, onereallocon the fourth push, every lookup freed with the store, a failedreallocand a store without a method stack freeing the new lookup), andguest_libressl_x509_store.tools/check_test_registration.py buildandpython3 tools/check_conventions.py --base upstream/mainpass. Not tested on Windows, on a title or on a console.tools/pr_overlap.pywas not run (no authenticatedgh).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 MarcZX10 on 2026-10-25T18:08:19Z.
Review: CHANGES_REQUESTED
Reviewed exact head
e8d6c3fb477fe583c554efd13b6ba88752eecb91.X509_STORE_add_lookup_nid_postfixallocateslookupat line 227 before rejecting a nullmethodor a method with an unsupportednewItemcallback. Both checks throw before the lookup is added tostore->lookupMethods, so the store cannot reclaim that block.tests/X509Lookup.cpp::Unsupportedcatches both exceptions and confirms the store remains unchanged, but it does not check allocator balance; repeated caught calls therefore leak one guest-heap allocation each.Please validate
methodandmethod->newItembefore allocating, or explicitly free the local lookup before throwing. Extend the allocator test to assert these rejected cases do not leave an allocation outstanding. This is limited to the two already-tested error paths; the normal lookup allocation and cleanup tests can remain as they are.