Commit b4f55c6f authored by Krists Krilovs's avatar Krists Krilovs Committed by Shane Lontis
Browse files

Fix wrong lock claimed in x509 dir lookup.



x509 store's objects cache can get corrupted when using dir lookup
method in multithreaded application. Claim x509 store's lock when
accessing objects cache.

CLA: trivial

Reviewed-by: default avatarRichard Levitte <levitte@openssl.org>
Reviewed-by: default avatarTomas Mraz <tmraz@fedoraproject.org>
Reviewed-by: default avatarBernd Edlinger <bernd.edlinger@hotmail.de>
Reviewed-by: default avatarPaul Dale <paul.dale@oracle.com>
Reviewed-by: default avatarShane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/9326)

(cherry picked from commit a161738a708b5e284a4714edc0c976606ea7cb26)
parent ab2d477c
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -327,10 +327,10 @@ static int get_cert_by_subject(X509_LOOKUP *xl, X509_LOOKUP_TYPE type,
        /*
         * we have added it to the cache so now pull it out again
         */
        CRYPTO_THREAD_write_lock(ctx->lock);
        X509_STORE_lock(xl->store_ctx);
        j = sk_X509_OBJECT_find(xl->store_ctx->objs, &stmp);
        tmp = sk_X509_OBJECT_value(xl->store_ctx->objs, j);
        CRYPTO_THREAD_unlock(ctx->lock);
        X509_STORE_unlock(xl->store_ctx);

        /* If a CRL, update the last file suffix added for this */