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:53:14 +0000 (16:53 +0200)
commit339bbcd70c1d135b7cc064e2ce001bdb22fe702b
treefb17cef0f503818516c5608d3f5d56a0a3400531
parentddeb0d37dd28ffba1b94f5033c34e6581ab0f821
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)

(cherry picked from commit cd920f8fa1bb603a620bea697027f5573fadc12e)
crypto/objects/obj_dat.c