On Linux the first exception the allocation test throws goes through
libc's unwinder, which caches two frame descriptions with operator new
for the rest of the process. The test counted them as blocks leaked by
i2t_ASN1_OBJECT and failed every fault case. A first failing conversion
now runs before the counted cases, and the blocks it leaves are not
tracked. Against the head before the allocation fix the test still
reports the escaped exceptions.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
i2t_ASN1_OBJECT threw and was declared without parameters. It now
prints an object's long name, or its short name, or its dotted OID, as
OBJ_obj2txt does in LibreSSL 2.5.4, the version string the module
holds: the NID is the object's own or found by the same binary search
over the same order, an unassigned NID reports OBJ_R_UNKNOWN_NID for
each name lookup, a truncated subidentifier returns 0 after the parts
already written, and arcs past 64 bits are printed exactly.
The 956 objects (short and long names, NID, OID) and their search order
are generated from 2.5.4's objects.txt and obj_mac.num with its own
objects.pl and obj_dat.pl, so d2i code can later hand out the same
static objects LibreSSL does.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
SSL_get_ex_new_index and SSL_CTX_get_ex_new_index took the new, dup and
free callbacks as void*, which a caller passing real callbacks can't
convert to. They now take LibreSslExNew, LibreSslExDup and
LibreSslExFree, the guest-ABI forms of CRYPTO_EX_new, CRYPTO_EX_dup and
CRYPTO_EX_free from LibreSSL 2.5.4's ossl_typ.h. Reported by @MarcZX10.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The store test asserted that comparing two cached objects and freeing a
store that holds certificates, lookup methods or policy objects throw.
Those states are valid on the console and the throws are placeholders
until the objects are modelled, so the assertions would fail once they
are. The null store, missing verify parameters and null element array
cases stay.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
SSL_get_ex_new_index and SSL_CTX_get_ex_new_index number their indices
per class from 0, SSL_get_ex_data_X509_STORE_CTX_idx allocates its
class-5 index once, and CRYPTO_cleanup_all_ex_data releases every class.
An allocation failure returns -1 with ERR_R_MALLOC_FAILURE queued.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Validate the string and count its UTF-8 size first, then make the one
guest allocation and write into it, so no std::vector can throw
std::bad_alloc past the guest. Approach from @thepoppfish's review.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
X509_STORE_add_lookup allocated the lookup before it threw for a null
method or a guest new_item callback, so each caught refusal left one
guest heap block behind. Both checks now run before the allocation, and
the allocator test checks that a refused method allocates nothing.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Both exports threw and were declared without parameters. They follow
LibreSSL 2.5.4, unchanged in 2.7: X509_LOOKUP_file returns the static
80-byte file method, and X509_STORE_add_lookup returns the store's
lookup for a method, or mallocs a 32-byte lookup owned by the store and
pushes it on the store's methods, growing the stack the way sk_insert
does. X509_STORE_free now frees the store's lookups.
The file method's ctrl, which loads PEM files, throws: there is no
certificate model yet. Callbacks of guest-supplied methods throw
instead of being called.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Both exports threw and were declared without parameters. They follow
LibreSSL 2.5.4, unchanged in 2.7: set_hostflags stores the host
matching flags in the verify parameters' identity, and set1_ip_asc
parses an IPv4 or IPv6 address the way a2i_ipadd does, copies the 4 or
16 bytes into a guest malloc block that replaces the previous address,
and returns 0 without touching it for text the parser rejects. IPv4
parts are read with the guest sscanf, as the module would.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The three exports threw and were declared without parameters. They now
follow LibreSSL 2.5.4, the version the firmware 13.40 measurements
identify: X509_STORE_new allocates the 136-byte store with an empty
object cache, an empty lookup method stack and 64-byte verify
parameters at depth -1, X509_STORE_free drops a reference and frees the
store with its stacks, verify parameters and their host names, peer
name, email and IP, and X509_STORE_set_flags ORs the flags into the
verify parameters and adds the policy check for any policy flag.
No export adds certificates, CRLs or lookup methods yet, so freeing a
store that holds them, or verify parameters holding policy objects,
throws instead of freeing objects with no model.
Co-Authored-By: Claude Opus 5.5 <[email protected]>