ensure that ossl_obj_nid_lock is allocated before use
authorNeil Horman <nhorman@openssl.org>
Wed, 11 Oct 2023 13:34:02 +0000 (09:34 -0400)
committerTomas Mraz <tomas@openssl.org>
Wed, 18 Oct 2023 14:52:45 +0000 (16:52 +0200)
commitcd920f8fa1bb603a620bea697027f5573fadc12e
tree0249e438230b93d3710efd3a8bdaf8392da2315f
parentbd160912dcc5e39bcdc925d9aa6538f20e37ad16
ensure that ossl_obj_nid_lock is allocated before use

external calls to OBJ_new_nid will fail on an attempt to lock the
ossl_obj_nid_lock as it won't have been initalized yet.

Bifurcate OBJ_new_nid into an external and internal variant, in which
the former calls ossl_obj_write_lock (ensuring that the nid_lock is
initalized), while OBJ_create (the sole internal caller) uses the latter
to avoid having to drop and re-acquire the lock

Fixes #22337

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22350)
crypto/objects/obj_dat.c