Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't prefer ECDHE-ECDSA ciphers when the client appears to be Safari on OS X. #14

Closed
wants to merge 6 commits into from
Closed

Conversation

robstradling
Copy link
Contributor

OS X 10.8..10.8.3 has broken support for ECDHE-ECDSA ciphers.

@benlaurie
Copy link
Contributor

Merged at b7aa71a.

@benlaurie benlaurie closed this Oct 4, 2013
tomato42 referenced this pull request in tomato42/openssl May 24, 2015
This is in line with #14 to remove legacy AEAD code. The code is now more in
line with the vanilla source.
mattcaswell added a commit to mattcaswell/web that referenced this pull request Jun 13, 2017
These were largely removed in OpenSSL 0.9.7 and replaced with functions
and compatibility macros so this FAQ entry is no longer relevant.

Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from openssl/openssl#14)
@mspncp mspncp mentioned this pull request Aug 14, 2019
2 tasks
@kroeckx kroeckx mentioned this pull request Apr 4, 2020
1 task
CyberShadow pushed a commit to CyberShadow/openssl that referenced this pull request Aug 17, 2020
deimos.openssl.bio: Fix BIO_set_close macro
rsbeckerca added a commit to ituglib/openssl that referenced this pull request May 30, 2023
commit 65be16881b71f4d66c77664775c93340a7b89c6d
Author: Randall S. Becker <rsbecker@nexbridge.com>
Date:   Tue Feb 7 09:13:22 2023 -0700

    Squashed commit of the following:

    commit 44ea69d6aadbbf9b951335e5ed296eed019e9ffe
    Author: Randall S. Becker <rsbecker@nexbridge.com>
    Date:   Wed Nov 2 12:49:30 2022 -0600

        Squashed commit of the following:

        commit 1b3fb89163127047b0f99412b8a31522215b3bea
        Author: Randall S. Becker <rsbecker@nexbridge.com>
        Date:   Tue Oct 11 11:17:39 2022 -0600

            Squashed commit of the following:

            commit 6fd6179191702eb0562ccbfb22a37405c669b90e
            Author: Randall S. Becker <randall.becker@nexbridge.ca>
            Date:   Tue Jul 5 17:50:13 2022 -0400

                Missed include on NonStop for memcmp in test/v3ext.c

            commit d97281f16602e50f040756029b555645315253df
            Author: Randall S. Becker <randall.becker@nexbridge.ca>
            Date:   Tue Jul 5 10:37:54 2022 -0400

                Squashed commit of the following:

                commit 29708a562a1887a91de0fa6ca668c71871accde9
                Author: Richard Levitte <levitte@openssl.org>
                Date:   Tue Jul 5 11:08:33 2022 +0200

                    Prepare for 1.1.1q release

                    Reviewed-by: Paul Dale <pauli@openssl.org>
                    Release: yes

                commit 95a17c0ead00885452d13309eaffd04c1737d05d
                Author: Richard Levitte <levitte@openssl.org>
                Date:   Tue Jul 5 10:33:00 2022 +0200

                    Update copyright year

                    Reviewed-by: Paul Dale <pauli@openssl.org>
                    Release: yes

                commit 78ba51a3b8b505d8d03abca8fa95e4fb1464d94e
                Author: Richard Levitte <levitte@openssl.org>
                Date:   Tue Jul 5 10:25:00 2022 +0200

                    Update CHANGES and NEWS for upcoming release 1.1.1q

                    Reviewed-by: Paul Dale <pauli@openssl.org>
                    Release: yes

                commit 9131afdca30b6d1650af9ea6179569a80ab8cb06
                Author: Alex Chernyakhovsky <achernya@google.com>
                Date:   Thu Jun 16 12:02:37 2022 +1000

                    AES OCB test vectors

                    Add test vectors for AES OCB for x86 AES-NI multiple of 96 byte issue.

                    Co-authored-by: Alejandro Sedeño <asedeno@google.com>
                    Co-authored-by: David Benjamin <davidben@google.com>

                    Reviewed-by: Paul Dale <pauli@openssl.org>
                    Reviewed-by: Tomas Mraz <tomas@openssl.org>

                commit 919925673d6c9cfed3c1085497f5dfbbed5fc431
                Author: Alex Chernyakhovsky <achernya@google.com>
                Date:   Thu Jun 16 12:00:22 2022 +1000

                    Fix AES OCB encrypt/decrypt for x86 AES-NI

                    aesni_ocb_encrypt and aesni_ocb_decrypt operate by having a fast-path
                    that performs operations on 6 16-byte blocks concurrently (the
                    "grandloop") and then proceeds to handle the "short" tail (which can
                    be anywhere from 0 to 5 blocks) that remain.

                    As part of initialization, the assembly initializes $len to the true
                    length, less 96 bytes and converts it to a pointer so that the $inp
                    can be compared to it. Each iteration of "grandloop" checks to see if
                    there's a full 96-byte chunk to process, and if so, continues. Once
                    this has been exhausted, it falls through to "short", which handles
                    the remaining zero to five blocks.

                    Unfortunately, the jump at the end of "grandloop" had a fencepost
                    error, doing a `jb` ("jump below") rather than `jbe` (jump below or
                    equal). This should be `jbe`, as $inp is pointing to the *end* of the
                    chunk currently being handled. If $inp == $len, that means that
                    there's a whole 96-byte chunk waiting to be handled. If $inp > $len,
                    then there's 5 or fewer 16-byte blocks left to be handled, and the
                    fall-through is intended.

                    The net effect of `jb` instead of `jbe` is that the last 16-byte block
                    of the last 96-byte chunk was completely omitted. The contents of
                    `out` in this position were never written to. Additionally, since
                    those bytes were never processed, the authentication tag generated is
                    also incorrect.

                    The same fencepost error, and identical logic, exists in both
                    aesni_ocb_encrypt and aesni_ocb_decrypt.

                    This addresses CVE-2022-2097.

                    Co-authored-by: Alejandro Sedeño <asedeno@google.com>
                    Co-authored-by: David Benjamin <davidben@google.com>

                    Reviewed-by: Paul Dale <pauli@openssl.org>
                    Reviewed-by: Tomas Mraz <tomas@openssl.org>

                commit 6495cab1c876ad80ce983d848ccaa1dc286a63e1
                Author: slontis <shane.lontis@oracle.com>
                Date:   Fri Jul 1 13:47:11 2022 +1000

                    Fix bn_gcd code to check return value when calling BN_one()

                    BN_one() uses the expand function which calls malloc which may fail.
                    All other places that reference BN_one() check the return value.

                    The issue is triggered by a memory allocation failure.
                    Detected by PR #18355

                    Reviewed-by: Tomas Mraz <tomas@openssl.org>
                    Reviewed-by: Paul Dale <pauli@openssl.org>
                    (Merged from https://github.com/openssl/openssl/pull/18697)

                    (cherry picked from commit 7fe7cc57af3db1e497877f0329ba17609b2efc8b)

                commit 7a05fcb1fc276a7ecfe599d45655d4e617c5e2d4
                Author: xkernel <xkernel.wang@foxmail.com>
                Date:   Mon Jun 20 17:46:39 2022 +0800

                    v3_sxnet: add a check for the return of i2s_ASN1_INTEGER()

                    Reviewed-by: Matt Caswell <matt@openssl.org>
                    Reviewed-by: Ben Kaduk <kaduk@mit.edu>
                    (Merged from https://github.com/openssl/openssl/pull/18608)

                    (cherry picked from commit 9ef1f848a646565d4dd86e56542cf921d4921ad9)

                commit a1d80edcf830739131e0567dc03b1e80b7988b1e
                Author: Matt Caswell <matt@openssl.org>
                Date:   Fri Jun 10 15:58:58 2022 +0100

                    Fix range_should_be_prefix() to actually return the correct result

                    range_should_be_prefix() was misidentifying whether an IP address range
                    should in fact be represented as a prefix. This was due to a bug introduced
                    in commit 42d7d7dd which made this incorrect change:

                    -    OPENSSL_assert(memcmp(min, max, length) <= 0);
                    +    if (memcmp(min, max, length) <= 0)
                    +        return -1;

                    This error leads to incorrect DER being encoded/accepted.

                    Reported by Theo Buehler (@botovq)

                    Reviewed-by: Paul Dale <pauli@openssl.org>
                    Reviewed-by: Tomas Mraz <tomas@openssl.org>
                    (Merged from https://github.com/openssl/openssl/pull/18524)

                    (cherry picked from commit 30532e59f475e0066c030693e4d614311a9e0cae)
                    (cherry picked from commit 2c6550c6db9b1b69dc24f968b4ceb534edcf4841)

                commit 4c1cf6d39bb8e85658ac8c743dcff8ede730f76a
                Author: Bernd Edlinger <bernd.edlinger@hotmail.de>
                Date:   Fri Jun 17 10:25:24 2022 +0200

                    Fix compile issues in test/v3ext.c with no-rfc3779

                    There are no ASIdentifiers if OPENSSL_NO_RFC3779 is defined,
                    therefore the test cannot be compiled.

                    Reviewed-by: Matt Caswell <matt@openssl.org>
                    Reviewed-by: Tomas Mraz <tomas@openssl.org>
                    Reviewed-by: Paul Dale <pauli@openssl.org>
                    (Merged from https://github.com/openssl/openssl/pull/18634)

                    (cherry picked from commit b76efe61ea9710a8f69e1cb8caf1aeb2ba6f1ebe)
                    (cherry picked from commit 665ab12ed3f0d78e7cb6a55cdd2b83a2fe150232)

                commit 882573246695088d65956355ca6c954642dcac31
                Author: olszomal <Malgorzata.Olszowka@stunnel.org>
                Date:   Fri Jun 17 15:01:11 2022 +0200

                    SSL_get_current_cipher() and SSL_get_pending_cipher() return 'const SSL_CIPHER *'

                    Fix the documentation.

                    CLA: trivial

                    Reviewed-by: Matt Caswell <matt@openssl.org>
                    Reviewed-by: Todd Short <todd.short@me.com>
                    Reviewed-by: Paul Dale <pauli@openssl.org>
                    Reviewed-by: Tomas Mraz <tomas@openssl.org>
                    (Merged from https://github.com/openssl/openssl/pull/18599)

                    (cherry picked from commit d842b6eff0940b6ce337536cb718a8d561290f50)

                commit 6c8879c8bf6030666c851623f93fff03c1266715
                Author: Bernd Edlinger <bernd.edlinger@hotmail.de>
                Date:   Wed Jun 22 17:05:55 2022 +0200

                    Fix a memory leak in EC_GROUP_new_from_ecparameters

                    This can be reproduced with my error injection patch.

                    The test vector has been validated on the 1.1.1 branch
                    but the issue is of course identical in all branches.

                    $ ERROR_INJECT=1656112173 ../util/shlib_wrap.sh ./x509-test ./corpora/x509/fe543a8d7e09109a9a08114323eefec802ad79e2
                        #0 0x7fb61945eeba in __sanitizer_print_stack_trace ../../../../gcc-trunk/libsanitizer/asan/asan_stack.cpp:87
                        #1 0x402f84 in my_malloc fuzz/test-corpus.c:114
                        #2 0x7fb619092430 in CRYPTO_zalloc crypto/mem.c:230
                        #3 0x7fb618ef7561 in bn_expand_internal crypto/bn/bn_lib.c:280
                        #4 0x7fb618ef7561 in bn_expand2 crypto/bn/bn_lib.c:304
                        #5 0x7fb618ef819d in BN_bin2bn crypto/bn/bn_lib.c:454
                        #6 0x7fb618e7aa13 in asn1_string_to_bn crypto/asn1/a_int.c:503
                        #7 0x7fb618e7aa13 in ASN1_INTEGER_to_BN crypto/asn1/a_int.c:559
                        #8 0x7fb618fd8e79 in EC_GROUP_new_from_ecparameters crypto/ec/ec_asn1.c:814
                        #9 0x7fb618fd98e8 in EC_GROUP_new_from_ecpkparameters crypto/ec/ec_asn1.c:935
                        #10 0x7fb618fd9aec in d2i_ECPKParameters crypto/ec/ec_asn1.c:966
                        #11 0x7fb618fdace9 in d2i_ECParameters crypto/ec/ec_asn1.c:1184
                        #12 0x7fb618fd1fc7 in eckey_type2param crypto/ec/ec_ameth.c:119
                        #13 0x7fb618fd57b4 in eckey_pub_decode crypto/ec/ec_ameth.c:165
                        #14 0x7fb6191a9c62 in x509_pubkey_decode crypto/x509/x_pubkey.c:124
                        #15 0x7fb6191a9e42 in pubkey_cb crypto/x509/x_pubkey.c:46
                        #16 0x7fb618eac032 in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:432
                        #17 0x7fb618eacaf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
                        #18 0x7fb618ead288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
                        #19 0x7fb618eab9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                        #20 0x7fb618eacaf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
                        #21 0x7fb618ead288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
                        #22 0x7fb618eab9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                        #23 0x7fb618eadd1f in ASN1_item_ex_d2i crypto/asn1/tasn_dec.c:124
                        #24 0x7fb618eade35 in ASN1_item_d2i crypto/asn1/tasn_dec.c:114
                        #25 0x40310c in FuzzerTestOneInput fuzz/x509.c:33
                        #26 0x402afb in testfile fuzz/test-corpus.c:182
                        #27 0x402656 in main fuzz/test-corpus.c:226
                        #28 0x7fb618551f44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21f44)
                        #29 0x402756  (/home/ed/OPC/openssl/fuzz/x509-test+0x402756)

                    =================================================================
                    ==12221==ERROR: LeakSanitizer: detected memory leaks

                    Direct leak of 24 byte(s) in 1 object(s) allocated from:
                        #0 0x7fb61945309f in __interceptor_malloc ../../../../gcc-trunk/libsanitizer/asan/asan_malloc_linux.cpp:69
                        #1 0x7fb619092430 in CRYPTO_zalloc crypto/mem.c:230
                        #2 0x7fb618ef5f11 in BN_new crypto/bn/bn_lib.c:246
                        #3 0x7fb618ef82f4 in BN_bin2bn crypto/bn/bn_lib.c:440
                        #4 0x7fb618fd8933 in EC_GROUP_new_from_ecparameters crypto/ec/ec_asn1.c:618
                        #5 0x7fb618fd98e8 in EC_GROUP_new_from_ecpkparameters crypto/ec/ec_asn1.c:935
                        #6 0x7fb618fd9aec in d2i_ECPKParameters crypto/ec/ec_asn1.c:966
                        #7 0x7fb618fdace9 in d2i_ECParameters crypto/ec/ec_asn1.c:1184
                        #8 0x7fb618fd1fc7 in eckey_type2param crypto/ec/ec_ameth.c:119
                        #9 0x7fb618fd57b4 in eckey_pub_decode crypto/ec/ec_ameth.c:165
                        #10 0x7fb6191a9c62 in x509_pubkey_decode crypto/x509/x_pubkey.c:124
                        #11 0x7fb6191a9e42 in pubkey_cb crypto/x509/x_pubkey.c:46
                        #12 0x7fb618eac032 in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:432
                        #13 0x7fb618eacaf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
                        #14 0x7fb618ead288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
                        #15 0x7fb618eab9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                        #16 0x7fb618eacaf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
                        #17 0x7fb618ead288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
                        #18 0x7fb618eab9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                        #19 0x7fb618eadd1f in ASN1_item_ex_d2i crypto/asn1/tasn_dec.c:124
                        #20 0x7fb618eade35 in ASN1_item_d2i crypto/asn1/tasn_dec.c:114
                        #21 0x40310c in FuzzerTestOneInput fuzz/x509.c:33
                        #22 0x402afb in testfile fuzz/test-corpus.c:182
                        #23 0x402656 in main fuzz/test-corpus.c:226
                        #24 0x7fb618551f44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21f44)

                    Indirect leak of 56 byte(s) in 1 object(s) allocated from:
                        #0 0x7fb61945309f in __interceptor_malloc ../../../../gcc-trunk/libsanitizer/asan/asan_malloc_linux.cpp:69
                        #1 0x7fb619092430 in CRYPTO_zalloc crypto/mem.c:230
                        #2 0x7fb618ef7561 in bn_expand_internal crypto/bn/bn_lib.c:280
                        #3 0x7fb618ef7561 in bn_expand2 crypto/bn/bn_lib.c:304
                        #4 0x7fb618ef819d in BN_bin2bn crypto/bn/bn_lib.c:454
                        #5 0x7fb618fd8933 in EC_GROUP_new_from_ecparameters crypto/ec/ec_asn1.c:618
                        #6 0x7fb618fd98e8 in EC_GROUP_new_from_ecpkparameters crypto/ec/ec_asn1.c:935
                        #7 0x7fb618fd9aec in d2i_ECPKParameters crypto/ec/ec_asn1.c:966
                        #8 0x7fb618fdace9 in d2i_ECParameters crypto/ec/ec_asn1.c:1184
                        #9 0x7fb618fd1fc7 in eckey_type2param crypto/ec/ec_ameth.c:119
                        #10 0x7fb618fd57b4 in eckey_pub_decode crypto/ec/ec_ameth.c:165
                        #11 0x7fb6191a9c62 in x509_pubkey_decode crypto/x509/x_pubkey.c:124
                        #12 0x7fb6191a9e42 in pubkey_cb crypto/x509/x_pubkey.c:46
                        #13 0x7fb618eac032 in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:432
                        #14 0x7fb618eacaf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
                        #15 0x7fb618ead288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
                        #16 0x7fb618eab9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                        #17 0x7fb618eacaf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
                        #18 0x7fb618ead288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
                        #19 0x7fb618eab9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                        #20 0x7fb618eadd1f in ASN1_item_ex_d2i crypto/asn1/tasn_dec.c:124
                        #21 0x7fb618eade35 in ASN1_item_d2i crypto/asn1/tasn_dec.c:114
                        #22 0x40310c in FuzzerTestOneInput fuzz/x509.c:33
                        #23 0x402afb in testfile fuzz/test-corpus.c:182
                        #24 0x402656 in main fuzz/test-corpus.c:226
                        #25 0x7fb618551f44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21f44)

                    SUMMARY: AddressSanitizer: 80 byte(s) leaked in 2 allocation(s).

                    Reviewed-by: Tomas Mraz <tomas@openssl.org>
                    Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
                    (Merged from https://github.com/openssl/openssl/pull/18632)

                commit 7f77ecd2facbd9df62ed727fbd1f522376d44bd3
                Author: Matt Caswell <matt@openssl.org>
                Date:   Tue Jun 21 14:39:48 2022 +0100

                    Prepare for 1.1.1q-dev

                    Reviewed-by: Richard Levitte <levitte@openssl.org>
                    Release: yes

                commit 8aaca20cf9996257d1ce2e6f4d3059b3698dde3d
                Author: Matt Caswell <matt@openssl.org>
                Date:   Tue Jun 21 14:39:39 2022 +0100

                    Prepare for 1.1.1p release

                    Reviewed-by: Richard Levitte <levitte@openssl.org>
                    Release: yes

                commit a3fc812c0c78e2f5db8b9d45bddaff62dfc958ae
                Author: Matt Caswell <matt@openssl.org>
                Date:   Tue Jun 21 14:07:32 2022 +0100

                    Update copyright year

                    Reviewed-by: Richard Levitte <levitte@openssl.org>
                    Release: yes

                commit 51e06520734063d6f52b2e596e1089d36d3781e7
                Author: Matt Caswell <matt@openssl.org>
                Date:   Mon Jun 20 14:14:20 2022 +0100

                    Update CHANGES and NEWS for new release

                    Reviewed-by: Tomas Mraz <tomas@openssl.org>
                    Release: yes

                commit 9639817dac8bbbaa64d09efad7464ccc405527c7
                Author: Daniel Fiala <daniel@openssl.org>
                Date:   Sun May 29 20:11:24 2022 +0200

                    Fix file operations in c_rehash.

                    CVE-2022-2068

                    Reviewed-by: Matt Caswell <matt@openssl.org>
                    Reviewed-by: Richard Levitte <levitte@openssl.org>

                commit 20af01d46ca4086f6b1339b67c15c81d8b4a040d
                Author: Fraser Tweedale <ftweedal@redhat.com>
                Date:   Wed Jun 15 10:50:57 2022 +1000

                    Fix documentation of BIO_FLAGS_BASE64_NO_NL

                    Commit 8bfb7506d210841f2ee4eda8afe96441a0e33fa5 updated
                    `BIO_f_base64(3)` to improve the documentation of the
                    `BIO_FLAGS_BASE64_NO_NL` flag.  In particular, the updated text
                    states that when this flag is used, all newlines in the input are
                    ignored.  This is incorrect, as the following program proves:

                    ```c

                    unsigned char *in_buf =
                        "IlRoZSBxdWljayBicm93biBmb3gganVt\ncHMgb3ZlciBhIGxhenkgZG9nLiI=\n";

                    int main(int argc, char **argv) {
                        BIO *b64 = BIO_new(BIO_f_base64());
                        if (b64 == NULL) return 1;
                        BIO_set_flags(b64, BIO_get_flags(b64) | BIO_FLAGS_BASE64_NO_NL);
                        int in_len = strlen(in_buf);
                        BIO *in = BIO_new_mem_buf(in_buf, in_len);
                        if (in == NULL) return 2;
                        in = BIO_push(b64, in);
                        unsigned char *out_buf = calloc(in_len, sizeof(unsigned char));
                        if (out_buf == NULL) return 3;
                        size_t out_len;
                        int r = BIO_read_ex(in, out_buf, in_len, &out_len);
                        printf("rv = %d\n", r);
                        printf("decoded = %s\n", out_buf);
                        return 0;
                    }
                    ```

                    Update the text of `BIO_f_base64(3)` to clarify that when the flag
                    is set, the data must be all on one line (with or without a trailing
                    newline character).

                    Signed-off-by: Fraser Tweedale <ftweedal@redhat.com>

                    Reviewed-by: Paul Dale <pauli@openssl.org>
                    Reviewed-by: Tomas Mraz <tomas@openssl.org>
                    (Merged from https://github.com/openssl/openssl/pull/18568)

                    (cherry picked from commit 0edcbacca99ab2b716da395f204610fc2775ea83)

                commit 8438d3a7b7309cbea521d3628fddeda7bd6d6e20
                Author: Tomas Mraz <tomas@openssl.org>
                Date:   Thu Jun 9 16:20:05 2022 +0200

                    Add an extra reduction step to RSAZ mod_exp implementations

                    Inspired by BoringSSL fix by David Benjamin.

                    Reviewed-by: Matt Caswell <matt@openssl.org>
                    Reviewed-by: Paul Dale <pauli@openssl.org>
                    (Merged from https://github.com/openssl/openssl/pull/18511)

                commit 0ed27fb7a8d85685cb671bf0a1e41bcdfc2624dc
                Author: Tomas Mraz <tomas@openssl.org>
                Date:   Thu Jun 9 12:34:55 2022 +0200

                    Always end BN_mod_exp_mont_consttime with normal Montgomery reduction.

                    This partially fixes a bug where, on x86_64, BN_mod_exp_mont_consttime
                    would sometimes return m, the modulus, when it should have returned
                    zero. Thanks to Guido Vranken for reporting it. It is only a partial fix
                    because the same bug also exists in the "rsaz" codepath.

                    The bug only affects zero outputs (with non-zero inputs), so we believe
                    it has no security impact on our cryptographic functions.

                    The fx is to delete lowercase bn_from_montgomery altogether, and have the
                    mont5 path use the same BN_from_montgomery ending as the non-mont5 path.
                    This only impacts the final step of the whole exponentiation and has no
                    measurable perf impact.

                    See the original BoringSSL commit
                    https://boringssl.googlesource.com/boringssl/+/13c9d5c69d04485a7a8840c12185c832026c8315
                    for further analysis.

                    Original-author: David Benjamin <davidben@google.com>

                    Reviewed-by: Matt Caswell <matt@openssl.org>
                    Reviewed-by: Paul Dale <pauli@openssl.org>
                    (Merged from https://github.com/openssl/openssl/pull/18511)

                commit 8f078819556da83c15751678c39558a59bc746fc
                Author: Matt Caswell <matt@openssl.org>
                Date:   Thu Jun 9 16:57:30 2022 +0100

                    Fix a crash in X509v3_asid_subset()

                    If the asnum or rdi fields are NULL and the ASIdentifiers are otherwise
                    subsets then this will result in a crash. Of note is that rdi will usually
                    be NULL.

                    Reported by Theo Buehler (@botovq)

                    Reviewed-by: Tomas Mraz <tomas@openssl.org>
                    Reviewed-by: Paul Yang <kaishen.yy@antfin.com>
                    Reviewed-by: Todd Short <todd.short@me.com>
                    (Merged from https://github.com/openssl/openssl/pull/18514)

                    (cherry picked from commit 01fc9b6bce82f0534d6673659a0e59a71f57ee82)

                commit ab7d05617a444cfcf4f930f81caa4cf66495ab9b
                Author: Tomas Mraz <tomas@openssl.org>
                Date:   Thu Jun 2 18:12:05 2022 +0200

                    Update further expiring certificates that affect tests

                    Namely the smime certificates used in test_cms
                    will expire soon and affect tests.

                    Fixes #15179

                    Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
                    Reviewed-by: Paul Dale <pauli@openssl.org>
                    (Merged from https://github.com/openssl/openssl/pull/18481)

                commit 3bd976551e549c030bdbd150c7aa8a1980cb00fe
                Author: Tomas Mraz <tomas@openssl.org>
                Date:   Tue Mar 29 13:31:34 2022 +0200

                    Fix strict client chain check with TLS-1.3

                    When TLS-1.3 is used and the server does not send any CA names
                    the ca_dn will be NULL. sk_X509_NAME_num() returns -1 on null
                    argument.

                    Reviewed-by: Todd Short <todd.short@me.com>
                    Reviewed-by: Matt Caswell <matt@openssl.org>
                    (Merged from https://github.com/openssl/openssl/pull/17986)

                    (cherry picked from commit 89dd85430770d39cbfb15eb586c921958ca7687f)

                commit b7ce611887cfac633aacc052b2e71a7f195418b8
                Author: Tomas Mraz <tomas@openssl.org>
                Date:   Wed Jun 1 13:06:46 2022 +0200

                    ct_test.c: Update the epoch time

                    Reviewed-by: Matt Caswell <matt@openssl.org>
                    Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
                    (Merged from https://github.com/openssl/openssl/pull/18446)

                commit 73db5d82489b3ec09ccc772dfcee14fef0e8e908
                Author: Tomas Mraz <tomas@openssl.org>
                Date:   Wed Jun 1 12:47:44 2022 +0200

                    Update expired SCT certificates

                    Reviewed-by: Matt Caswell <matt@openssl.org>
                    Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
                    (Merged from https://github.com/openssl/openssl/pull/18446)

                commit 8754fa5f60ac4fdb5127f2eded9c7bbe0651c880
                Author: Bernd Edlinger <bernd.edlinger@hotmail.de>
                Date:   Sat May 21 07:50:46 2022 +0200

                    Fix a memory leak in crl_set_issuers

                    This can be reproduced with my error injection patch.

                    The test vector has been validated on the 1.1.1 branch
                    but the issue is of course identical in all branches.

                    $ ERROR_INJECT=1653520461 ../util/shlib_wrap.sh ./cms-test ./corpora/cms/3eff1d2f1232bd66d5635db2c3f9e7f23830dfd1
                    log file: cms-3eff1d2f1232bd66d5635db2c3f9e7f23830dfd1-32454-test.out
                    ERROR_INJECT=1653520461
                        #0 0x7fd5d8b8eeba in __sanitizer_print_stack_trace ../../../../gcc-trunk/libsanitizer/asan/asan_stack.cpp:87
                        #1 0x402fc4 in my_realloc fuzz/test-corpus.c:129
                        #2 0x7fd5d8893c49 in sk_reserve crypto/stack/stack.c:198
                        #3 0x7fd5d8893c49 in OPENSSL_sk_insert crypto/stack/stack.c:242
                        #4 0x7fd5d88d6d7f in sk_GENERAL_NAMES_push include/openssl/x509v3.h:168
                        #5 0x7fd5d88d6d7f in crl_set_issuers crypto/x509/x_crl.c:111
                        #6 0x7fd5d88d6d7f in crl_cb crypto/x509/x_crl.c:246
                        #7 0x7fd5d85dc032 in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:432
                        #8 0x7fd5d85dcaf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
                        #9 0x7fd5d85dd288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
                        #10 0x7fd5d85db2b5 in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:259
                        #11 0x7fd5d85dc813 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:611
                        #12 0x7fd5d85dd288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
                        #13 0x7fd5d85db9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                        #14 0x7fd5d85dca28 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:633
                        #15 0x7fd5d85dd288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
                        #16 0x7fd5d85db9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                        #17 0x7fd5d85dcaf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
                        #18 0x7fd5d85dd7d3 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:494
                        #19 0x7fd5d85db9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                        #20 0x7fd5d85ddd1f in ASN1_item_ex_d2i crypto/asn1/tasn_dec.c:124
                        #21 0x7fd5d85dde35 in ASN1_item_d2i crypto/asn1/tasn_dec.c:114
                        #22 0x7fd5d85a77e0 in ASN1_item_d2i_bio crypto/asn1/a_d2i_fp.c:69
                        #23 0x402845 in FuzzerTestOneInput fuzz/cms.c:43
                        #24 0x402bbb in testfile fuzz/test-corpus.c:182
                        #25 0x402626 in main fuzz/test-corpus.c:226
                        #26 0x7fd5d7c81f44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21f44)
                        #27 0x402706  (/home/ed/OPC/openssl/fuzz/cms-test+0x402706)

                    =================================================================
                    ==29625==ERROR: LeakSanitizer: detected memory leaks

                    Direct leak of 32 byte(s) in 1 object(s) allocated from:
                        #0 0x7fd5d8b8309f in __interceptor_malloc ../../../../gcc-trunk/libsanitizer/asan/asan_malloc_linux.cpp:69
                        #1 0x7fd5d87c2430 in CRYPTO_zalloc crypto/mem.c:230
                        #2 0x7fd5d889501f in OPENSSL_sk_new_reserve crypto/stack/stack.c:209
                        #3 0x7fd5d85dcbc3 in sk_ASN1_VALUE_new_null include/openssl/asn1t.h:928
                        #4 0x7fd5d85dcbc3 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:577
                        #5 0x7fd5d85dd288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
                        #6 0x7fd5d85db104 in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:178
                        #7 0x7fd5d85ddd1f in ASN1_item_ex_d2i crypto/asn1/tasn_dec.c:124
                        #8 0x7fd5d85dde35 in ASN1_item_d2i crypto/asn1/tasn_dec.c:114
                        #9 0x7fd5d88f86d9 in X509V3_EXT_d2i crypto/x509v3/v3_lib.c:142
                        #10 0x7fd5d88d6d3c in crl_set_issuers crypto/x509/x_crl.c:97
                        #11 0x7fd5d88d6d3c in crl_cb crypto/x509/x_crl.c:246
                        #12 0x7fd5d85dc032 in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:432
                        #13 0x7fd5d85dcaf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
                        #14 0x7fd5d85dd288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
                        #15 0x7fd5d85db2b5 in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:259
                        #16 0x7fd5d85dc813 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:611
                        #17 0x7fd5d85dd288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
                        #18 0x7fd5d85db9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                        #19 0x7fd5d85dca28 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:633
                        #20 0x7fd5d85dd288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
                        #21 0x7fd5d85db9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                        #22 0x7fd5d85dcaf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
                        #23 0x7fd5d85dd7d3 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:494
                        #24 0x7fd5d85db9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                        #25 0x7fd5d85ddd1f in ASN1_item_ex_d2i crypto/asn1/tasn_dec.c:124
                        #26 0x7fd5d85dde35 in ASN1_item_d2i crypto/asn1/tasn_dec.c:114
                        #27 0x7fd5d85a77e0 in ASN1_item_d2i_bio crypto/asn1/a_d2i_fp.c:69
                        #28 0x402845 in FuzzerTestOneInput fuzz/cms.c:43
                        #29 0x402bbb in testfile fuzz/test-corpus.c:182
                        #30 0x402626 in main fuzz/test-corpus.c:226
                        #31 0x7fd5d7c81f44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21f44)

                    SUMMARY: AddressSanitizer: 32 byte(s) leaked in 1 allocation(s).

                    Reviewed-by: Paul Dale <pauli@openssl.org>
                    Reviewed-by: Tomas Mraz <tomas@openssl.org>
                    (Merged from https://github.com/openssl/openssl/pull/18391)

                    (cherry picked from commit e9007e09792e3735d4973743634ff55d354fc7d8)

                commit 4a28f8451fbc1848fd2d1b99203a7c75876123f6
                Author: Bernd Edlinger <bernd.edlinger@hotmail.de>
                Date:   Sun May 22 20:12:56 2022 +0200

                    Fix a crash in ssl_security_cert_chain

                    Prior to the crash there is an out of memory error
                    in X509_verify_cert which makes the chain NULL or
                    empty.  The error is ignored by ssl_add_cert_chain,
                    and ssl_security_cert_chain crashes due to the
                    unchecked null pointer.

                    This is reproducible with my error injection patch.

                    The test vector has been validated on the 1.1.1 branch
                    but the issue is of course identical in all branches.

                    $ ERROR_INJECT=1652848273 ../util/shlib_wrap.sh ./server-test ./corpora/server/47c8e933c4ec66fa3c309422283dfe0f31aafae8# ./corpora/server/47c8e933c4ec66fa3c309422283dfe0f31aafae8
                        #0 0x7f3a8f766eba in __sanitizer_print_stack_trace ../../../../gcc-trunk/libsanitizer/asan/asan_stack.cpp:87
                        #1 0x403ba4 in my_malloc fuzz/test-corpus.c:114
                        #2 0x7f3a8f39a430 in CRYPTO_zalloc crypto/mem.c:230
                        #3 0x7f3a8f46bd3b in sk_reserve crypto/stack/stack.c:180
                        #4 0x7f3a8f46bd3b in OPENSSL_sk_insert crypto/stack/stack.c:242
                        #5 0x7f3a8f4a4fd8 in sk_X509_push include/openssl/x509.h:99
                        #6 0x7f3a8f4a4fd8 in X509_verify_cert crypto/x509/x509_vfy.c:286
                        #7 0x7f3a8fed726e in ssl_add_cert_chain ssl/statem/statem_lib.c:959
                        #8 0x7f3a8fed726e in ssl3_output_cert_chain ssl/statem/statem_lib.c:1015
                        #9 0x7f3a8fee1c50 in tls_construct_server_certificate ssl/statem/statem_srvr.c:3812
                        #10 0x7f3a8feb8b0a in write_state_machine ssl/statem/statem.c:843
                        #11 0x7f3a8feb8b0a in state_machine ssl/statem/statem.c:443
                        #12 0x7f3a8fe84b3f in SSL_do_handshake ssl/ssl_lib.c:3718
                        #13 0x403202 in FuzzerTestOneInput fuzz/server.c:740
                        #14 0x40371b in testfile fuzz/test-corpus.c:182
                        #15 0x402856 in main fuzz/test-corpus.c:226
                        #16 0x7f3a8e859f44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21f44)
                        #17 0x402936  (/home/ed/OPC/openssl/fuzz/server-test+0x402936)

                    AddressSanitizer:DEADLYSIGNAL
                    =================================================================
                    ==8400==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000158 (pc 0x7f3a8f4d822f bp 0x7ffc39b76190 sp 0x7ffc39b760a0 T0)
                    ==8400==The signal is caused by a READ memory access.
                    ==8400==Hint: address points to the zero page.
                        #0 0x7f3a8f4d822f in x509v3_cache_extensions crypto/x509v3/v3_purp.c:386
                        #1 0x7f3a8f4d9d3a in X509_check_purpose crypto/x509v3/v3_purp.c:84
                        #2 0x7f3a8f4da02a in X509_get_extension_flags crypto/x509v3/v3_purp.c:921
                        #3 0x7f3a8feff7d2 in ssl_security_cert_sig ssl/t1_lib.c:2518
                        #4 0x7f3a8feff7d2 in ssl_security_cert ssl/t1_lib.c:2542
                        #5 0x7f3a8feffa03 in ssl_security_cert_chain ssl/t1_lib.c:2562
                        #6 0x7f3a8fed728d in ssl_add_cert_chain ssl/statem/statem_lib.c:963
                        #7 0x7f3a8fed728d in ssl3_output_cert_chain ssl/statem/statem_lib.c:1015
                        #8 0x7f3a8fee1c50 in tls_construct_server_certificate ssl/statem/statem_srvr.c:3812
                        #9 0x7f3a8feb8b0a in write_state_machine ssl/statem/statem.c:843
                        #10 0x7f3a8feb8b0a in state_machine ssl/statem/statem.c:443
                        #11 0x7f3a8fe84b3f in SSL_do_handshake ssl/ssl_lib.c:3718
                        #12 0x403202 in FuzzerTestOneInput fuzz/server.c:740
                        #13 0x40371b in testfile fuzz/test-corpus.c:182
                        #14 0x402856 in main fuzz/test-corpus.c:226
                        #15 0x7f3a8e859f44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21f44)
                        #16 0x402936  (/home/ed/OPC/openssl/fuzz/server-test+0x402936)

                    AddressSanitizer can not provide additional info.
                    SUMMARY: AddressSanitizer: SEGV crypto/x509v3/v3_purp.c:386 in x509v3_cache_extensions
                    ==8400==ABORTING

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

                    (cherry picked from commit dc0ef292f7df4ce0c49c64b47726a6768f9ac044)

                commit 59b8eca400d9ea7b77dc98fe08a91bbfe35d025a
                Author: Bernd Edlinger <bernd.edlinger@hotmail.de>
                Date:   Sat May 21 15:41:46 2022 +0200

                    Fix a memory leak in X509_issuer_and_serial_hash

                    This is reproducible with my error injection patch:

                    $ ERROR_INJECT=1653267699 ../util/shlib_wrap.sh ./x509-test ./corpora/x509/5f4034ae85d6587dcad4da3e812e80f3d312894d
                    ERROR_INJECT=1653267699
                        #0 0x7fd485a6ad4f in __sanitizer_print_stack_trace ../../../../src/libsanitizer/asan/asan_stack.cc:36
                        #1 0x55c12d268724 in my_malloc fuzz/test-corpus.c:114
                        #2 0x7fd484f51a75 in CRYPTO_zalloc crypto/mem.c:230
                        #3 0x7fd484ed778d in EVP_DigestInit_ex crypto/evp/digest.c:139
                        #4 0x7fd4850a9849 in X509_issuer_and_serial_hash crypto/x509/x509_cmp.c:44
                        #5 0x55c12d268951 in FuzzerTestOneInput fuzz/x509.c:44
                        #6 0x55c12d268239 in testfile fuzz/test-corpus.c:182
                        #7 0x55c12d267c7f in main fuzz/test-corpus.c:226
                        #8 0x7fd483a42082 in __libc_start_main ../csu/libc-start.c:308
                        #9 0x55c12d267e5d in _start (/home/ed/OPCToolboxV5/Source/Core/OpenSSL/openssl/fuzz/x509-test+0x3e5d)

                    =================================================================
                    ==1058475==ERROR: LeakSanitizer: detected memory leaks

                    Direct leak of 268 byte(s) in 1 object(s) allocated from:
                        #0 0x7fd485a5dc3e in __interceptor_realloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:163
                        #1 0x7fd484d2eb9b in BUF_MEM_grow crypto/buffer/buffer.c:97
                        #2 0x7fd4850b2913 in X509_NAME_oneline crypto/x509/x509_obj.c:43
                        #3 0x7fd4850a982f in X509_issuer_and_serial_hash crypto/x509/x509_cmp.c:41
                        #4 0x55c12d268951 in FuzzerTestOneInput fuzz/x509.c:44
                        #5 0x55c12d268239 in testfile fuzz/test-corpus.c:182
                        #6 0x55c12d267c7f in main fuzz/test-corpus.c:226
                        #7 0x7fd483a42082 in __libc_start_main ../csu/libc-start.c:308

                    SUMMARY: AddressSanitizer: 268 byte(s) leaked in 1 allocation(s).

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

                commit e4b84b7514e5cbcbfc80e31b4ce609c7584e14bb
                Author: Bernd Edlinger <bernd.edlinger@hotmail.de>
                Date:   Fri May 20 16:54:41 2022 +0200

                    Fix undefined behaviour in EC_GROUP_new_from_ecparameters

                    This happens for instance with
                    fuzz/corpora/asn1/65cf44e85614c62f10cf3b7a7184c26293a19e4a
                    and causes the OPENSSL_malloc below to choke on the
                    zero length allocation request.

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

                commit 8e1ece20cdb4a584be5311370256c4e813c09826
                Author: Bernd Edlinger <bernd.edlinger@hotmail.de>
                Date:   Fri May 20 16:15:44 2022 +0200

                    Fix a memory leak in ec_key_simple_oct2priv

                    This is reproducible with my error injection patch:

                    $ ERROR_INJECT=1652710284 ../util/shlib_wrap.sh ./server-test ./corpora/server/4e48da8aecce6b9b58e8e4dbbf0523e6d2dd56dc
                    140587884632000:error:03078041:bignum routines:bn_expand_internal:malloc failure:crypto/bn/bn_lib.c:282:
                    140587884632000:error:10103003:elliptic curve routines:ec_key_simple_oct2priv:BN lib:crypto/ec/ec_key.c:662:
                    140587884632000:error:100DE08E:elliptic curve routines:old_ec_priv_decode:decode error:crypto/ec/ec_ameth.c:464:
                    140587884632000:error:0D0680A8:asn1 encoding routines:asn1_check_tlen:wrong tag:crypto/asn1/tasn_dec.c:1149:
                    140587884632000:error:0D07803A:asn1 encoding routines:asn1_item_embed_d2i:nested asn1 error:crypto/asn1/tasn_dec.c:309:Type=X509_ALGOR
                    140587884632000:error:0D08303A:asn1 encoding routines:asn1_template_noexp_d2i:nested asn1 error:crypto/asn1/tasn_dec.c:646:Field=pkeyalg, Type=PKCS8_PRIV_KEY_INFO
                    140587884632000:error:0907B00D:PEM routines:PEM_read_bio_PrivateKey:ASN1 lib:crypto/pem/pem_pkey.c:88:

                    =================================================================
                    ==19676==ERROR: LeakSanitizer: detected memory leaks

                    Direct leak of 24 byte(s) in 1 object(s) allocated from:
                        #0 0x7fdd2a6bb09f in __interceptor_malloc ../../../../gcc-trunk/libsanitizer/asan/asan_malloc_linux.cpp:69
                        #1 0x7fdd2a2fa430 in CRYPTO_zalloc crypto/mem.c:230
                        #2 0x7fdd2a15df11 in BN_new crypto/bn/bn_lib.c:246
                        #3 0x7fdd2a15df88 in BN_secure_new crypto/bn/bn_lib.c:257
                        #4 0x7fdd2a247390 in ec_key_simple_oct2priv crypto/ec/ec_key.c:655
                        #5 0x7fdd2a241fc5 in d2i_ECPrivateKey crypto/ec/ec_asn1.c:1030
                        #6 0x7fdd2a23dac5 in old_ec_priv_decode crypto/ec/ec_ameth.c:463
                        #7 0x7fdd2a109db7 in d2i_PrivateKey crypto/asn1/d2i_pr.c:46
                        #8 0x7fdd2a33ab16 in PEM_read_bio_PrivateKey crypto/pem/pem_pkey.c:84
                        #9 0x7fdd2a3330b6 in PEM_read_bio_ECPrivateKey crypto/pem/pem_all.c:151
                        #10 0x402dba in FuzzerTestOneInput fuzz/server.c:592
                        #11 0x40370b in testfile fuzz/test-corpus.c:182
                        #12 0x402846 in main fuzz/test-corpus.c:226
                        #13 0x7fdd297b9f44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21f44)

                    SUMMARY: AddressSanitizer: 24 byte(s) leaked in 1 allocation(s).

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

                commit 8e60f41d064786f95440e4c56660ffe9777783d7
                Author: Bernd Edlinger <bernd.edlinger@hotmail.de>
                Date:   Fri May 20 08:02:47 2022 +0200

                    Fix a crash in asn1_item_embed_new

                    This happens usually if an template object is created
                    and there is an out of memory error before the ASN1_OP_NEW_POST
                    method is called, but asn1_item_embed_free calls now the
                    ASN1_OP_FREE_POST which may crash because the object is not
                    properly initialized.  Apparently that is only an issue with
                    the ASN1_OP_FREE_POST handling of crypot/x509/x_crl.c, which
                    ought to be tolerant to incomplete initialized objects.

                    The error can be reproduced with the reproducible error injection patch:

                    $ ERROR_INJECT=1652890550 ../util/shlib_wrap.sh ./asn1-test ./corpora/asn1/0ff17293911f54d1538b9896563a4048d67d9ee4
                        #0 0x7faae9dbeeba in __sanitizer_print_stack_trace ../../../../gcc-trunk/libsanitizer/asan/asan_stack.cpp:87
                        #1 0x408dc4 in my_malloc fuzz/test-corpus.c:114
                        #2 0x7faae99f2430 in CRYPTO_zalloc crypto/mem.c:230
                        #3 0x7faae97f09e5 in ASN1_STRING_type_new crypto/asn1/asn1_lib.c:341
                        #4 0x7faae98118f7 in asn1_primitive_new crypto/asn1/tasn_new.c:318
                        #5 0x7faae9812401 in asn1_item_embed_new crypto/asn1/tasn_new.c:78
                        #6 0x7faae9812401 in asn1_template_new crypto/asn1/tasn_new.c:240
                        #7 0x7faae9812315 in asn1_item_embed_new crypto/asn1/tasn_new.c:137
                        #8 0x7faae9812315 in asn1_template_new crypto/asn1/tasn_new.c:240
                        #9 0x7faae9812a54 in asn1_item_embed_new crypto/asn1/tasn_new.c:137
                        #10 0x7faae9812a54 in ASN1_item_ex_new crypto/asn1/tasn_new.c:39
                        #11 0x7faae980be51 in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:325
                        #12 0x7faae980c813 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:611
                        #13 0x7faae980d288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
                        #14 0x7faae980b9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                        #15 0x7faae980caf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
                        #16 0x7faae980d7d3 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:494
                        #17 0x7faae980b9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                        #18 0x7faae980dd1f in ASN1_item_ex_d2i crypto/asn1/tasn_dec.c:124
                        #19 0x7faae980de35 in ASN1_item_d2i crypto/asn1/tasn_dec.c:114
                        #20 0x40712c in FuzzerTestOneInput fuzz/asn1.c:301
                        #21 0x40893b in testfile fuzz/test-corpus.c:182
                        #22 0x406b86 in main fuzz/test-corpus.c:226
                        #23 0x7faae8eb1f44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21f44)

                    AddressSanitizer:DEADLYSIGNAL
                    =================================================================
                    ==1194==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000010 (pc 0x7faae9b0625f bp 0x7fffffe41a00 sp 0x7fffffe41920 T0)
                    ==1194==The signal is caused by a READ memory access.
                    ==1194==Hint: address points to the zero page.
                        #0 0x7faae9b0625f in crl_cb crypto/x509/x_crl.c:258
                        #1 0x7faae9811255 in asn1_item_embed_free crypto/asn1/tasn_fre.c:113
                        #2 0x7faae9812a65 in asn1_item_embed_new crypto/asn1/tasn_new.c:150
                        #3 0x7faae9812a65 in ASN1_item_ex_new crypto/asn1/tasn_new.c:39
                        #4 0x7faae980be51 in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:325
                        #5 0x7faae980c813 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:611
                        #6 0x7faae980d288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
                        #7 0x7faae980b9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                        #8 0x7faae980caf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
                        #9 0x7faae980d7d3 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:494
                        #10 0x7faae980b9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                        #11 0x7faae980dd1f in ASN1_item_ex_d2i crypto/asn1/tasn_dec.c:124
                        #12 0x7faae980de35 in ASN1_item_d2i crypto/asn1/tasn_dec.c:114
                        #13 0x40712c in FuzzerTestOneInput fuzz/asn1.c:301
                        #14 0x40893b in testfile fuzz/test-corpus.c:182
                        #15 0x406b86 in main fuzz/test-corpus.c:226
                        #16 0x7faae8eb1f44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21f44)

                    AddressSanitizer can not provide additional info.
                    SUMMARY: AddressSanitizer: SEGV crypto/x509/x_crl.c:258 in crl_cb
                    ==1194==ABORTING

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

                    (cherry picked from commit 557825acd622f98fc21423aba092e374db84f483)

                commit 17519e2595b5ed8211a7763ff6eb2d6cf47c13cb
                Author: Bernd Edlinger <bernd.edlinger@hotmail.de>
                Date:   Thu May 19 15:50:28 2022 +0200

                    Backport a missing bug-fix from master

                    This is a backport of the following commit from master:

                    commit 61b0fead5e6079ca826594df5b9ca00e65883cb0
                    Author: Matt Caswell <matt@openssl.org>
                    Date:   Thu Nov 19 13:58:21 2020 +0000

                        Don't Overflow when printing Thawte Strong Extranet Version

                        When printing human readable info on the Thawte Strong Extranet extension
                        the version number could overflow if the version number == LONG_MAX. This
                        is undefined behaviour.

                        Issue found by OSSFuzz.

                        Reviewed-by: Ben Kaduk <kaduk@mit.edu>
                        (Merged from https://github.com/openssl/openssl/pull/13452)

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

                commit 03ba56f1525c93eb3dfe72f85cdc698b97918e59
                Author: Bernd Edlinger <bernd.edlinger@hotmail.de>
                Date:   Thu May 19 10:59:25 2022 +0200

                    Backport some fuzzing data files from master

                    This is a backport of the following commit from master:

                    commit 415e6ac80405e13b20b083315747e431274fbd33
                    Author: Tavis Ormandy <taviso@gmail.com>
                    Date:   Tue Sep 21 15:48:27 2021 -0700

                        increase x509 code coverage metrics

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

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

                commit e04ba889594d84a8805f3d0caeadf0527470e508
                Author: Daniel Fiala <daniel@openssl.org>
                Date:   Tue May 10 08:46:37 2022 +0000

                    s_serve: Report an error if init-connection fails without an attempt to read.

                    Fixes: openssl#18047.

                    Reviewed-by: Paul Dale <pauli@openssl.org>
                    Reviewed-by: Tomas Mraz <tomas@openssl.org>
                    (Merged from https://github.com/openssl/openssl/pull/18283)

                commit 6ef91d8153e04a2302bff11b29caf7e888b62fe8
                Author: basavesh <basavesh.shivakumar@gmail.com>
                Date:   Tue Apr 5 17:49:09 2022 +0200

                    Fix leakage when the cacheline is 32-bytes in CBC_MAC_ROTATE_IN_PLACE

                    rotated_mac is a 64-byte aligned buffer of size 64 and rotate_offset is secret.
                    Consider a weaker leakage model(CL) where only cacheline base address is leaked,
                    i.e address/32 for 32-byte cacheline(CL32).

                    Previous code used to perform two loads
                        1. rotated_mac[rotate_offset ^ 32] and
                        2. rotated_mac[rotate_offset++]
                    which would leak 2q + 1, 2q for 0 <= rotate_offset < 32
                    and 2q, 2q + 1 for 32 <= rotate_offset < 64

                    The proposed fix performs load operations which will always leak 2q, 2q + 1 and
                    selects the appropriate value in constant-time.

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

                commit c7d6c08290b67cbeef2b4f636f04788ea405520a
                Author: Tomas Mraz <tomas@openssl.org>
                Date:   Fri Apr 29 17:02:19 2022 +0200

                    Add test for empty supported-groups extension

                    Reviewed-by: Paul Dale <pauli@openssl.org>
                    Reviewed-by: Matt Caswell <matt@openssl.org>
                    (Merged from https://github.com/openssl/openssl/pull/18213)

                commit bd164884f258d99ca876f6cdcdf9bd0dcceee6ad
                Author: Tomas Mraz <tomas@openssl.org>
                Date:   Fri Apr 29 16:36:36 2022 +0200

                    Do not send an empty supported groups extension

                    This allows handshake to proceed if the maximum TLS version enabled is <1.3

                    Fixes #13583

                    Reviewed-by: Paul Dale <pauli@openssl.org>
                    Reviewed-by: Matt Caswell <matt@openssl.org>
                    (Merged from https://github.com/openssl/openssl/pull/18213)

                commit ac2d4cb656b3a796db3dc6f8873e91e67907372d
                Author: Allan Jude <allan@klarasystems.com>
                Date:   Fri Nov 19 19:06:52 2021 +0000

                    1_1_1-stable: Detect arm64-*-*bsd and enable assembly optimizations

                    Reviewed-by: Paul Dale <pauli@openssl.org>
                    Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
                    Reviewed-by: Tomas Mraz <tomas@openssl.org>
                    (Merged from https://github.com/openssl/openssl/pull/17085)

                commit ec1b4bf26c1b2440546f323873c578374f60b2de
                Author: Hugo Landau <hlandau@openssl.org>
                Date:   Wed Apr 27 10:11:08 2022 +0100

                    (1.1) Add SSL_(CTX_)?get0_(verify|chain)_cert_store functions

                    Backport of #18038 to 1.1.

                    Fixes #18035.

                    Reviewed-by: Tomas Mraz <tomas@openssl.org>
                    Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
                    (Merged from https://github.com/openssl/openssl/pull/18190)

                commit 988c7b2d9361dd0ade5ef7ef068fb4ed770ce2a2
                Author: Matt Caswell <matt@openssl.org>
                Date:   Tue May 3 14:41:23 2022 +0100

                    Prepare for 1.1.1p-dev

                    Reviewed-by: Tomas Mraz <tomas@openssl.org>
                    Release: yes

            commit 5ea6414f0bf861e8fece53b5bf35c849bad64774
            Author: Randall S. Becker <rsbecker@nexbridge.com>
            Date:   Wed Jun 22 06:26:40 2022 -0600

                Squashed commit of the following:

                commit 8aaca20cf9996257d1ce2e6f4d3059b3698dde3d
                Author: Matt Caswell <matt@openssl.org>
                Date:   Tue Jun 21 14:39:39 2022 +0100

                    Prepare for 1.1.1p release

                    Reviewed-by: Richard Levitte <levitte@openssl.org>
                    Release: yes

                commit a3fc812c0c78e2f5db8b9d45bddaff62dfc958ae
                Author: Matt Caswell <matt@openssl.org>
                Date:   Tue Jun 21 14:07:32 2022 +0100

                    Update copyright year

                    Reviewed-by: Richard Levitte <levitte@openssl.org>
                    Release: yes

                commit 51e06520734063d6f52b2e596e1089d36d3781e7
                Author: Matt Caswell <matt@openssl.org>
                Date:   Mon Jun 20 14:14:20 2022 +0100

                    Update CHANGES and NEWS for new release

                    Reviewed-by: Tomas Mraz <tomas@openssl.org>
                    Release: yes

                commit 9639817dac8bbbaa64d09efad7464ccc405527c7
                Author: Daniel Fiala <daniel@openssl.org>
                Date:   Sun May 29 20:11:24 2022 +0200

                    Fix file operations in c_rehash.

                    CVE-2022-2068

                    Reviewed-by: Matt Caswell <matt@openssl.org>
                    Reviewed-by: Richard Levitte <levitte@openssl.org>

                commit 20af01d46ca4086f6b1339b67c15c81d8b4a040d
                Author: Fraser Tweedale <ftweedal@redhat.com>
                Date:   Wed Jun 15 10:50:57 2022 +1000

                    Fix documentation of BIO_FLAGS_BASE64_NO_NL

                    Commit 8bfb7506d210841f2ee4eda8afe96441a0e33fa5 updated
                    `BIO_f_base64(3)` to improve the documentation of the
                    `BIO_FLAGS_BASE64_NO_NL` flag.  In particular, the updated text
                    states that when this flag is used, all newlines in the input are
                    ignored.  This is incorrect, as the following program proves:

                    ```c

                    unsigned char *in_buf =
                        "IlRoZSBxdWljayBicm93biBmb3gganVt\ncHMgb3ZlciBhIGxhenkgZG9nLiI=\n";

                    int main(int argc, char **argv) {
                        BIO *b64 = BIO_new(BIO_f_base64());
                        if (b64 == NULL) return 1;
                        BIO_set_flags(b64, BIO_get_flags(b64) | BIO_FLAGS_BASE64_NO_NL);
                        int in_len = strlen(in_buf);
                        BIO *in = BIO_new_mem_buf(in_buf, in_len);
                        if (in == NULL) return 2;
                        in = BIO_push(b64, in);
                        unsigned char *out_buf = calloc(in_len, sizeof(unsigned char));
                        if (out_buf == NULL) return 3;
                        size_t out_len;
                        int r = BIO_read_ex(in, out_buf, in_len, &out_len);
                        printf("rv = %d\n", r);
                        printf("decoded = %s\n", out_buf);
                        return 0;
                    }
                    ```

                    Update the text of `BIO_f_base64(3)` to clarify that when the flag
                    is set, the data must be all on one line (with or without a trailing
                    newline character).

                    Signed-off-by: Fraser Tweedale <ftweedal@redhat.com>

                    Reviewed-by: Paul Dale <pauli@openssl.org>
                    Reviewed-by: Tomas Mraz <tomas@openssl.org>
                    (Merged from https://github.com/openssl/openssl/pull/18568)

                    (cherry picked from commit 0edcbacca99ab2b716da395f204610fc2775ea83)

                commit 8438d3a7b7309cbea521d3628fddeda7bd6d6e20
                Author: Tomas Mraz <tomas@openssl.org>
                Date:   Thu Jun 9 16:20:05 2022 +0200

                    Add an extra reduction step to RSAZ mod_exp implementations

                    Inspired by BoringSSL fix by David Benjamin.

                    Reviewed-by: Matt Caswell <matt@openssl.org>
                    Reviewed-by: Paul Dale <pauli@openssl.org>
                    (Merged from https://github.com/openssl/openssl/pull/18511)

                commit 0ed27fb7a8d85685cb671bf0a1e41bcdfc2624dc
                Author: Tomas Mraz <tomas@openssl.org>
                Date:   Thu Jun 9 12:34:55 2022 +0200

                    Always end BN_mod_exp_mont_consttime with normal Montgomery reduction.

                    This partially fixes a bug where, on x86_64, BN_mod_exp_mont_consttime
                    would sometimes return m, the modulus, when it should have returned
                    zero. Thanks to Guido Vranken for reporting it. It is only a partial fix
                    because the same bug also exists in the "rsaz" codepath.

                    The bug only affects zero outputs (with non-zero inputs), so we believe
                    it has no security impact on our cryptographic functions.

                    The fx is to delete lowercase bn_from_montgomery altogether, and have the
                    mont5 path use the same BN_from_montgomery ending as the non-mont5 path.
                    This only impacts the final step of the whole exponentiation and has no
                    measurable perf impact.

                    See the original BoringSSL commit
                    https://boringssl.googlesource.com/boringssl/+/13c9d5c69d04485a7a8840c12185c832026c8315
                    for further analysis.

                    Original-author: David Benjamin <davidben@google.com>

                    Reviewed-by: Matt Caswell <matt@openssl.org>
                    Reviewed-by: Paul Dale <pauli@openssl.org>
                    (Merged from https://github.com/openssl/openssl/pull/18511)

                commit 8f078819556da83c15751678c39558a59bc746fc
                Author: Matt Caswell <matt@openssl.org>
                Date:   Thu Jun 9 16:57:30 2022 +0100

                    Fix a crash in X509v3_asid_subset()

                    If the asnum or rdi fields are NULL and the ASIdentifiers are otherwise
                    subsets then this will result in a crash. Of note is that rdi will usually
                    be NULL.

                    Reported by Theo Buehler (@botovq)

                    Reviewed-by: Tomas Mraz <tomas@openssl.org>
                    Reviewed-by: Paul Yang <kaishen.yy@antfin.com>
                    Reviewed-by: Todd Short <todd.short@me.com>
                    (Merged from https://github.com/openssl/openssl/pull/18514)

                    (cherry picked from commit 01fc9b6bce82f0534d6673659a0e59a71f57ee82)

                commit ab7d05617a444cfcf4f930f81caa4cf66495ab9b
                Author: Tomas Mraz <tomas@openssl.org>
                Date:   Thu Jun 2 18:12:05 2022 +0200

                    Update further expiring certificates that affect tests

                    Namely the smime certificates used in test_cms
                    will expire soon and affect tests.

                    Fixes #15179

                    Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
                    Reviewed-by: Paul Dale <pauli@openssl.org>
                    (Merged from https://github.com/openssl/openssl/pull/18481)

                commit 3bd976551e549c030bdbd150c7aa8a1980cb00fe
                Author: Tomas Mraz <tomas@openssl.org>
                Date:   Tue Mar 29 13:31:34 2022 +0200

     …
tmshort pushed a commit to tmshort/openssl that referenced this pull request Aug 1, 2023
rsbeckerca added a commit to ituglib/openssl that referenced this pull request Aug 1, 2023
commit 84ef302bbb2c1bb9a3c10abfd31984e2a8731e7f
Author: Randall S. Becker <rsbecker@nexbridge.com>
Date:   Tue May 30 08:30:00 2023 -0600

    Merged OpenSSL 1.1.1u with ituglib_release

    commit 65be16881b71f4d66c77664775c93340a7b89c6d
    Author: Randall S. Becker <rsbecker@nexbridge.com>
    Date:   Tue Feb 7 09:13:22 2023 -0700

        Squashed commit of the following:

        commit 44ea69d6aadbbf9b951335e5ed296eed019e9ffe
        Author: Randall S. Becker <rsbecker@nexbridge.com>
        Date:   Wed Nov 2 12:49:30 2022 -0600

            Squashed commit of the following:

            commit 1b3fb89163127047b0f99412b8a31522215b3bea
            Author: Randall S. Becker <rsbecker@nexbridge.com>
            Date:   Tue Oct 11 11:17:39 2022 -0600

                Squashed commit of the following:

                commit 6fd6179191702eb0562ccbfb22a37405c669b90e
                Author: Randall S. Becker <randall.becker@nexbridge.ca>
                Date:   Tue Jul 5 17:50:13 2022 -0400

                    Missed include on NonStop for memcmp in test/v3ext.c

                commit d97281f16602e50f040756029b555645315253df
                Author: Randall S. Becker <randall.becker@nexbridge.ca>
                Date:   Tue Jul 5 10:37:54 2022 -0400

                    Squashed commit of the following:

                    commit 29708a562a1887a91de0fa6ca668c71871accde9
                    Author: Richard Levitte <levitte@openssl.org>
                    Date:   Tue Jul 5 11:08:33 2022 +0200

                        Prepare for 1.1.1q release

                        Reviewed-by: Paul Dale <pauli@openssl.org>
                        Release: yes

                    commit 95a17c0ead00885452d13309eaffd04c1737d05d
                    Author: Richard Levitte <levitte@openssl.org>
                    Date:   Tue Jul 5 10:33:00 2022 +0200

                        Update copyright year

                        Reviewed-by: Paul Dale <pauli@openssl.org>
                        Release: yes

                    commit 78ba51a3b8b505d8d03abca8fa95e4fb1464d94e
                    Author: Richard Levitte <levitte@openssl.org>
                    Date:   Tue Jul 5 10:25:00 2022 +0200

                        Update CHANGES and NEWS for upcoming release 1.1.1q

                        Reviewed-by: Paul Dale <pauli@openssl.org>
                        Release: yes

                    commit 9131afdca30b6d1650af9ea6179569a80ab8cb06
                    Author: Alex Chernyakhovsky <achernya@google.com>
                    Date:   Thu Jun 16 12:02:37 2022 +1000

                        AES OCB test vectors

                        Add test vectors for AES OCB for x86 AES-NI multiple of 96 byte issue.

                        Co-authored-by: Alejandro Sedeño <asedeno@google.com>
                        Co-authored-by: David Benjamin <davidben@google.com>

                        Reviewed-by: Paul Dale <pauli@openssl.org>
                        Reviewed-by: Tomas Mraz <tomas@openssl.org>

                    commit 919925673d6c9cfed3c1085497f5dfbbed5fc431
                    Author: Alex Chernyakhovsky <achernya@google.com>
                    Date:   Thu Jun 16 12:00:22 2022 +1000

                        Fix AES OCB encrypt/decrypt for x86 AES-NI

                        aesni_ocb_encrypt and aesni_ocb_decrypt operate by having a fast-path
                        that performs operations on 6 16-byte blocks concurrently (the
                        "grandloop") and then proceeds to handle the "short" tail (which can
                        be anywhere from 0 to 5 blocks) that remain.

                        As part of initialization, the assembly initializes $len to the true
                        length, less 96 bytes and converts it to a pointer so that the $inp
                        can be compared to it. Each iteration of "grandloop" checks to see if
                        there's a full 96-byte chunk to process, and if so, continues. Once
                        this has been exhausted, it falls through to "short", which handles
                        the remaining zero to five blocks.

                        Unfortunately, the jump at the end of "grandloop" had a fencepost
                        error, doing a `jb` ("jump below") rather than `jbe` (jump below or
                        equal). This should be `jbe`, as $inp is pointing to the *end* of the
                        chunk currently being handled. If $inp == $len, that means that
                        there's a whole 96-byte chunk waiting to be handled. If $inp > $len,
                        then there's 5 or fewer 16-byte blocks left to be handled, and the
                        fall-through is intended.

                        The net effect of `jb` instead of `jbe` is that the last 16-byte block
                        of the last 96-byte chunk was completely omitted. The contents of
                        `out` in this position were never written to. Additionally, since
                        those bytes were never processed, the authentication tag generated is
                        also incorrect.

                        The same fencepost error, and identical logic, exists in both
                        aesni_ocb_encrypt and aesni_ocb_decrypt.

                        This addresses CVE-2022-2097.

                        Co-authored-by: Alejandro Sedeño <asedeno@google.com>
                        Co-authored-by: David Benjamin <davidben@google.com>

                        Reviewed-by: Paul Dale <pauli@openssl.org>
                        Reviewed-by: Tomas Mraz <tomas@openssl.org>

                    commit 6495cab1c876ad80ce983d848ccaa1dc286a63e1
                    Author: slontis <shane.lontis@oracle.com>
                    Date:   Fri Jul 1 13:47:11 2022 +1000

                        Fix bn_gcd code to check return value when calling BN_one()

                        BN_one() uses the expand function which calls malloc which may fail.
                        All other places that reference BN_one() check the return value.

                        The issue is triggered by a memory allocation failure.
                        Detected by PR #18355

                        Reviewed-by: Tomas Mraz <tomas@openssl.org>
                        Reviewed-by: Paul Dale <pauli@openssl.org>
                        (Merged from https://github.com/openssl/openssl/pull/18697)

                        (cherry picked from commit 7fe7cc57af3db1e497877f0329ba17609b2efc8b)

                    commit 7a05fcb1fc276a7ecfe599d45655d4e617c5e2d4
                    Author: xkernel <xkernel.wang@foxmail.com>
                    Date:   Mon Jun 20 17:46:39 2022 +0800

                        v3_sxnet: add a check for the return of i2s_ASN1_INTEGER()

                        Reviewed-by: Matt Caswell <matt@openssl.org>
                        Reviewed-by: Ben Kaduk <kaduk@mit.edu>
                        (Merged from https://github.com/openssl/openssl/pull/18608)

                        (cherry picked from commit 9ef1f848a646565d4dd86e56542cf921d4921ad9)

                    commit a1d80edcf830739131e0567dc03b1e80b7988b1e
                    Author: Matt Caswell <matt@openssl.org>
                    Date:   Fri Jun 10 15:58:58 2022 +0100

                        Fix range_should_be_prefix() to actually return the correct result

                        range_should_be_prefix() was misidentifying whether an IP address range
                        should in fact be represented as a prefix. This was due to a bug introduced
                        in commit 42d7d7dd which made this incorrect change:

                        -    OPENSSL_assert(memcmp(min, max, length) <= 0);
                        +    if (memcmp(min, max, length) <= 0)
                        +        return -1;

                        This error leads to incorrect DER being encoded/accepted.

                        Reported by Theo Buehler (@botovq)

                        Reviewed-by: Paul Dale <pauli@openssl.org>
                        Reviewed-by: Tomas Mraz <tomas@openssl.org>
                        (Merged from https://github.com/openssl/openssl/pull/18524)

                        (cherry picked from commit 30532e59f475e0066c030693e4d614311a9e0cae)
                        (cherry picked from commit 2c6550c6db9b1b69dc24f968b4ceb534edcf4841)

                    commit 4c1cf6d39bb8e85658ac8c743dcff8ede730f76a
                    Author: Bernd Edlinger <bernd.edlinger@hotmail.de>
                    Date:   Fri Jun 17 10:25:24 2022 +0200

                        Fix compile issues in test/v3ext.c with no-rfc3779

                        There are no ASIdentifiers if OPENSSL_NO_RFC3779 is defined,
                        therefore the test cannot be compiled.

                        Reviewed-by: Matt Caswell <matt@openssl.org>
                        Reviewed-by: Tomas Mraz <tomas@openssl.org>
                        Reviewed-by: Paul Dale <pauli@openssl.org>
                        (Merged from https://github.com/openssl/openssl/pull/18634)

                        (cherry picked from commit b76efe61ea9710a8f69e1cb8caf1aeb2ba6f1ebe)
                        (cherry picked from commit 665ab12ed3f0d78e7cb6a55cdd2b83a2fe150232)

                    commit 882573246695088d65956355ca6c954642dcac31
                    Author: olszomal <Malgorzata.Olszowka@stunnel.org>
                    Date:   Fri Jun 17 15:01:11 2022 +0200

                        SSL_get_current_cipher() and SSL_get_pending_cipher() return 'const SSL_CIPHER *'

                        Fix the documentation.

                        CLA: trivial

                        Reviewed-by: Matt Caswell <matt@openssl.org>
                        Reviewed-by: Todd Short <todd.short@me.com>
                        Reviewed-by: Paul Dale <pauli@openssl.org>
                        Reviewed-by: Tomas Mraz <tomas@openssl.org>
                        (Merged from https://github.com/openssl/openssl/pull/18599)

                        (cherry picked from commit d842b6eff0940b6ce337536cb718a8d561290f50)

                    commit 6c8879c8bf6030666c851623f93fff03c1266715
                    Author: Bernd Edlinger <bernd.edlinger@hotmail.de>
                    Date:   Wed Jun 22 17:05:55 2022 +0200

                        Fix a memory leak in EC_GROUP_new_from_ecparameters

                        This can be reproduced with my error injection patch.

                        The test vector has been validated on the 1.1.1 branch
                        but the issue is of course identical in all branches.

                        $ ERROR_INJECT=1656112173 ../util/shlib_wrap.sh ./x509-test ./corpora/x509/fe543a8d7e09109a9a08114323eefec802ad79e2
                            #0 0x7fb61945eeba in __sanitizer_print_stack_trace ../../../../gcc-trunk/libsanitizer/asan/asan_stack.cpp:87
                            #1 0x402f84 in my_malloc fuzz/test-corpus.c:114
                            #2 0x7fb619092430 in CRYPTO_zalloc crypto/mem.c:230
                            #3 0x7fb618ef7561 in bn_expand_internal crypto/bn/bn_lib.c:280
                            #4 0x7fb618ef7561 in bn_expand2 crypto/bn/bn_lib.c:304
                            #5 0x7fb618ef819d in BN_bin2bn crypto/bn/bn_lib.c:454
                            #6 0x7fb618e7aa13 in asn1_string_to_bn crypto/asn1/a_int.c:503
                            #7 0x7fb618e7aa13 in ASN1_INTEGER_to_BN crypto/asn1/a_int.c:559
                            #8 0x7fb618fd8e79 in EC_GROUP_new_from_ecparameters crypto/ec/ec_asn1.c:814
                            #9 0x7fb618fd98e8 in EC_GROUP_new_from_ecpkparameters crypto/ec/ec_asn1.c:935
                            #10 0x7fb618fd9aec in d2i_ECPKParameters crypto/ec/ec_asn1.c:966
                            #11 0x7fb618fdace9 in d2i_ECParameters crypto/ec/ec_asn1.c:1184
                            #12 0x7fb618fd1fc7 in eckey_type2param crypto/ec/ec_ameth.c:119
                            #13 0x7fb618fd57b4 in eckey_pub_decode crypto/ec/ec_ameth.c:165
                            #14 0x7fb6191a9c62 in x509_pubkey_decode crypto/x509/x_pubkey.c:124
                            #15 0x7fb6191a9e42 in pubkey_cb crypto/x509/x_pubkey.c:46
                            #16 0x7fb618eac032 in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:432
                            #17 0x7fb618eacaf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
                            #18 0x7fb618ead288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
                            #19 0x7fb618eab9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                            #20 0x7fb618eacaf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
                            #21 0x7fb618ead288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
                            #22 0x7fb618eab9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                            #23 0x7fb618eadd1f in ASN1_item_ex_d2i crypto/asn1/tasn_dec.c:124
                            #24 0x7fb618eade35 in ASN1_item_d2i crypto/asn1/tasn_dec.c:114
                            #25 0x40310c in FuzzerTestOneInput fuzz/x509.c:33
                            #26 0x402afb in testfile fuzz/test-corpus.c:182
                            #27 0x402656 in main fuzz/test-corpus.c:226
                            #28 0x7fb618551f44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21f44)
                            #29 0x402756  (/home/ed/OPC/openssl/fuzz/x509-test+0x402756)

                        =================================================================
                        ==12221==ERROR: LeakSanitizer: detected memory leaks

                        Direct leak of 24 byte(s) in 1 object(s) allocated from:
                            #0 0x7fb61945309f in __interceptor_malloc ../../../../gcc-trunk/libsanitizer/asan/asan_malloc_linux.cpp:69
                            #1 0x7fb619092430 in CRYPTO_zalloc crypto/mem.c:230
                            #2 0x7fb618ef5f11 in BN_new crypto/bn/bn_lib.c:246
                            #3 0x7fb618ef82f4 in BN_bin2bn crypto/bn/bn_lib.c:440
                            #4 0x7fb618fd8933 in EC_GROUP_new_from_ecparameters crypto/ec/ec_asn1.c:618
                            #5 0x7fb618fd98e8 in EC_GROUP_new_from_ecpkparameters crypto/ec/ec_asn1.c:935
                            #6 0x7fb618fd9aec in d2i_ECPKParameters crypto/ec/ec_asn1.c:966
                            #7 0x7fb618fdace9 in d2i_ECParameters crypto/ec/ec_asn1.c:1184
                            #8 0x7fb618fd1fc7 in eckey_type2param crypto/ec/ec_ameth.c:119
                            #9 0x7fb618fd57b4 in eckey_pub_decode crypto/ec/ec_ameth.c:165
                            #10 0x7fb6191a9c62 in x509_pubkey_decode crypto/x509/x_pubkey.c:124
                            #11 0x7fb6191a9e42 in pubkey_cb crypto/x509/x_pubkey.c:46
                            #12 0x7fb618eac032 in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:432
                            #13 0x7fb618eacaf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
                            #14 0x7fb618ead288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
                            #15 0x7fb618eab9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                            #16 0x7fb618eacaf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
                            #17 0x7fb618ead288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
                            #18 0x7fb618eab9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                            #19 0x7fb618eadd1f in ASN1_item_ex_d2i crypto/asn1/tasn_dec.c:124
                            #20 0x7fb618eade35 in ASN1_item_d2i crypto/asn1/tasn_dec.c:114
                            #21 0x40310c in FuzzerTestOneInput fuzz/x509.c:33
                            #22 0x402afb in testfile fuzz/test-corpus.c:182
                            #23 0x402656 in main fuzz/test-corpus.c:226
                            #24 0x7fb618551f44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21f44)

                        Indirect leak of 56 byte(s) in 1 object(s) allocated from:
                            #0 0x7fb61945309f in __interceptor_malloc ../../../../gcc-trunk/libsanitizer/asan/asan_malloc_linux.cpp:69
                            #1 0x7fb619092430 in CRYPTO_zalloc crypto/mem.c:230
                            #2 0x7fb618ef7561 in bn_expand_internal crypto/bn/bn_lib.c:280
                            #3 0x7fb618ef7561 in bn_expand2 crypto/bn/bn_lib.c:304
                            #4 0x7fb618ef819d in BN_bin2bn crypto/bn/bn_lib.c:454
                            #5 0x7fb618fd8933 in EC_GROUP_new_from_ecparameters crypto/ec/ec_asn1.c:618
                            #6 0x7fb618fd98e8 in EC_GROUP_new_from_ecpkparameters crypto/ec/ec_asn1.c:935
                            #7 0x7fb618fd9aec in d2i_ECPKParameters crypto/ec/ec_asn1.c:966
                            #8 0x7fb618fdace9 in d2i_ECParameters crypto/ec/ec_asn1.c:1184
                            #9 0x7fb618fd1fc7 in eckey_type2param crypto/ec/ec_ameth.c:119
                            #10 0x7fb618fd57b4 in eckey_pub_decode crypto/ec/ec_ameth.c:165
                            #11 0x7fb6191a9c62 in x509_pubkey_decode crypto/x509/x_pubkey.c:124
                            #12 0x7fb6191a9e42 in pubkey_cb crypto/x509/x_pubkey.c:46
                            #13 0x7fb618eac032 in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:432
                            #14 0x7fb618eacaf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
                            #15 0x7fb618ead288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
                            #16 0x7fb618eab9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                            #17 0x7fb618eacaf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
                            #18 0x7fb618ead288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
                            #19 0x7fb618eab9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                            #20 0x7fb618eadd1f in ASN1_item_ex_d2i crypto/asn1/tasn_dec.c:124
                            #21 0x7fb618eade35 in ASN1_item_d2i crypto/asn1/tasn_dec.c:114
                            #22 0x40310c in FuzzerTestOneInput fuzz/x509.c:33
                            #23 0x402afb in testfile fuzz/test-corpus.c:182
                            #24 0x402656 in main fuzz/test-corpus.c:226
                            #25 0x7fb618551f44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21f44)

                        SUMMARY: AddressSanitizer: 80 byte(s) leaked in 2 allocation(s).

                        Reviewed-by: Tomas Mraz <tomas@openssl.org>
                        Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
                        (Merged from https://github.com/openssl/openssl/pull/18632)

                    commit 7f77ecd2facbd9df62ed727fbd1f522376d44bd3
                    Author: Matt Caswell <matt@openssl.org>
                    Date:   Tue Jun 21 14:39:48 2022 +0100

                        Prepare for 1.1.1q-dev

                        Reviewed-by: Richard Levitte <levitte@openssl.org>
                        Release: yes

                    commit 8aaca20cf9996257d1ce2e6f4d3059b3698dde3d
                    Author: Matt Caswell <matt@openssl.org>
                    Date:   Tue Jun 21 14:39:39 2022 +0100

                        Prepare for 1.1.1p release

                        Reviewed-by: Richard Levitte <levitte@openssl.org>
                        Release: yes

                    commit a3fc812c0c78e2f5db8b9d45bddaff62dfc958ae
                    Author: Matt Caswell <matt@openssl.org>
                    Date:   Tue Jun 21 14:07:32 2022 +0100

                        Update copyright year

                        Reviewed-by: Richard Levitte <levitte@openssl.org>
                        Release: yes

                    commit 51e06520734063d6f52b2e596e1089d36d3781e7
                    Author: Matt Caswell <matt@openssl.org>
                    Date:   Mon Jun 20 14:14:20 2022 +0100

                        Update CHANGES and NEWS for new release

                        Reviewed-by: Tomas Mraz <tomas@openssl.org>
                        Release: yes

                    commit 9639817dac8bbbaa64d09efad7464ccc405527c7
                    Author: Daniel Fiala <daniel@openssl.org>
                    Date:   Sun May 29 20:11:24 2022 +0200

                        Fix file operations in c_rehash.

                        CVE-2022-2068

                        Reviewed-by: Matt Caswell <matt@openssl.org>
                        Reviewed-by: Richard Levitte <levitte@openssl.org>

                    commit 20af01d46ca4086f6b1339b67c15c81d8b4a040d
                    Author: Fraser Tweedale <ftweedal@redhat.com>
                    Date:   Wed Jun 15 10:50:57 2022 +1000

                        Fix documentation of BIO_FLAGS_BASE64_NO_NL

                        Commit 8bfb7506d210841f2ee4eda8afe96441a0e33fa5 updated
                        `BIO_f_base64(3)` to improve the documentation of the
                        `BIO_FLAGS_BASE64_NO_NL` flag.  In particular, the updated text
                        states that when this flag is used, all newlines in the input are
                        ignored.  This is incorrect, as the following program proves:

                        ```c

                        unsigned char *in_buf =
                            "IlRoZSBxdWljayBicm93biBmb3gganVt\ncHMgb3ZlciBhIGxhenkgZG9nLiI=\n";

                        int main(int argc, char **argv) {
                            BIO *b64 = BIO_new(BIO_f_base64());
                            if (b64 == NULL) return 1;
                            BIO_set_flags(b64, BIO_get_flags(b64) | BIO_FLAGS_BASE64_NO_NL);
                            int in_len = strlen(in_buf);
                            BIO *in = BIO_new_mem_buf(in_buf, in_len);
                            if (in == NULL) return 2;
                            in = BIO_push(b64, in);
                            unsigned char *out_buf = calloc(in_len, sizeof(unsigned char));
                            if (out_buf == NULL) return 3;
                            size_t out_len;
                            int r = BIO_read_ex(in, out_buf, in_len, &out_len);
                            printf("rv = %d\n", r);
                            printf("decoded = %s\n", out_buf);
                            return 0;
                        }
                        ```

                        Update the text of `BIO_f_base64(3)` to clarify that when the flag
                        is set, the data must be all on one line (with or without a trailing
                        newline character).

                        Signed-off-by: Fraser Tweedale <ftweedal@redhat.com>

                        Reviewed-by: Paul Dale <pauli@openssl.org>
                        Reviewed-by: Tomas Mraz <tomas@openssl.org>
                        (Merged from https://github.com/openssl/openssl/pull/18568)

                        (cherry picked from commit 0edcbacca99ab2b716da395f204610fc2775ea83)

                    commit 8438d3a7b7309cbea521d3628fddeda7bd6d6e20
                    Author: Tomas Mraz <tomas@openssl.org>
                    Date:   Thu Jun 9 16:20:05 2022 +0200

                        Add an extra reduction step to RSAZ mod_exp implementations

                        Inspired by BoringSSL fix by David Benjamin.

                        Reviewed-by: Matt Caswell <matt@openssl.org>
                        Reviewed-by: Paul Dale <pauli@openssl.org>
                        (Merged from https://github.com/openssl/openssl/pull/18511)

                    commit 0ed27fb7a8d85685cb671bf0a1e41bcdfc2624dc
                    Author: Tomas Mraz <tomas@openssl.org>
                    Date:   Thu Jun 9 12:34:55 2022 +0200

                        Always end BN_mod_exp_mont_consttime with normal Montgomery reduction.

                        This partially fixes a bug where, on x86_64, BN_mod_exp_mont_consttime
                        would sometimes return m, the modulus, when it should have returned
                        zero. Thanks to Guido Vranken for reporting it. It is only a partial fix
                        because the same bug also exists in the "rsaz" codepath.

                        The bug only affects zero outputs (with non-zero inputs), so we believe
                        it has no security impact on our cryptographic functions.

                        The fx is to delete lowercase bn_from_montgomery altogether, and have the
                        mont5 path use the same BN_from_montgomery ending as the non-mont5 path.
                        This only impacts the final step of the whole exponentiation and has no
                        measurable perf impact.

                        See the original BoringSSL commit
                        https://boringssl.googlesource.com/boringssl/+/13c9d5c69d04485a7a8840c12185c832026c8315
                        for further analysis.

                        Original-author: David Benjamin <davidben@google.com>

                        Reviewed-by: Matt Caswell <matt@openssl.org>
                        Reviewed-by: Paul Dale <pauli@openssl.org>
                        (Merged from https://github.com/openssl/openssl/pull/18511)

                    commit 8f078819556da83c15751678c39558a59bc746fc
                    Author: Matt Caswell <matt@openssl.org>
                    Date:   Thu Jun 9 16:57:30 2022 +0100

                        Fix a crash in X509v3_asid_subset()

                        If the asnum or rdi fields are NULL and the ASIdentifiers are otherwise
                        subsets then this will result in a crash. Of note is that rdi will usually
                        be NULL.

                        Reported by Theo Buehler (@botovq)

                        Reviewed-by: Tomas Mraz <tomas@openssl.org>
                        Reviewed-by: Paul Yang <kaishen.yy@antfin.com>
                        Reviewed-by: Todd Short <todd.short@me.com>
                        (Merged from https://github.com/openssl/openssl/pull/18514)

                        (cherry picked from commit 01fc9b6bce82f0534d6673659a0e59a71f57ee82)

                    commit ab7d05617a444cfcf4f930f81caa4cf66495ab9b
                    Author: Tomas Mraz <tomas@openssl.org>
                    Date:   Thu Jun 2 18:12:05 2022 +0200

                        Update further expiring certificates that affect tests

                        Namely the smime certificates used in test_cms
                        will expire soon and affect tests.

                        Fixes #15179

                        Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
                        Reviewed-by: Paul Dale <pauli@openssl.org>
                        (Merged from https://github.com/openssl/openssl/pull/18481)

                    commit 3bd976551e549c030bdbd150c7aa8a1980cb00fe
                    Author: Tomas Mraz <tomas@openssl.org>
                    Date:   Tue Mar 29 13:31:34 2022 +0200

                        Fix strict client chain check with TLS-1.3

                        When TLS-1.3 is used and the server does not send any CA names
                        the ca_dn will be NULL. sk_X509_NAME_num() returns -1 on null
                        argument.

                        Reviewed-by: Todd Short <todd.short@me.com>
                        Reviewed-by: Matt Caswell <matt@openssl.org>
                        (Merged from https://github.com/openssl/openssl/pull/17986)

                        (cherry picked from commit 89dd85430770d39cbfb15eb586c921958ca7687f)

                    commit b7ce611887cfac633aacc052b2e71a7f195418b8
                    Author: Tomas Mraz <tomas@openssl.org>
                    Date:   Wed Jun 1 13:06:46 2022 +0200

                        ct_test.c: Update the epoch time

                        Reviewed-by: Matt Caswell <matt@openssl.org>
                        Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
                        (Merged from https://github.com/openssl/openssl/pull/18446)

                    commit 73db5d82489b3ec09ccc772dfcee14fef0e8e908
                    Author: Tomas Mraz <tomas@openssl.org>
                    Date:   Wed Jun 1 12:47:44 2022 +0200

                        Update expired SCT certificates

                        Reviewed-by: Matt Caswell <matt@openssl.org>
                        Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
                        (Merged from https://github.com/openssl/openssl/pull/18446)

                    commit 8754fa5f60ac4fdb5127f2eded9c7bbe0651c880
                    Author: Bernd Edlinger <bernd.edlinger@hotmail.de>
                    Date:   Sat May 21 07:50:46 2022 +0200

                        Fix a memory leak in crl_set_issuers

                        This can be reproduced with my error injection patch.

                        The test vector has been validated on the 1.1.1 branch
                        but the issue is of course identical in all branches.

                        $ ERROR_INJECT=1653520461 ../util/shlib_wrap.sh ./cms-test ./corpora/cms/3eff1d2f1232bd66d5635db2c3f9e7f23830dfd1
                        log file: cms-3eff1d2f1232bd66d5635db2c3f9e7f23830dfd1-32454-test.out
                        ERROR_INJECT=1653520461
                            #0 0x7fd5d8b8eeba in __sanitizer_print_stack_trace ../../../../gcc-trunk/libsanitizer/asan/asan_stack.cpp:87
                            #1 0x402fc4 in my_realloc fuzz/test-corpus.c:129
                            #2 0x7fd5d8893c49 in sk_reserve crypto/stack/stack.c:198
                            #3 0x7fd5d8893c49 in OPENSSL_sk_insert crypto/stack/stack.c:242
                            #4 0x7fd5d88d6d7f in sk_GENERAL_NAMES_push include/openssl/x509v3.h:168
                            #5 0x7fd5d88d6d7f in crl_set_issuers crypto/x509/x_crl.c:111
                            #6 0x7fd5d88d6d7f in crl_cb crypto/x509/x_crl.c:246
                            #7 0x7fd5d85dc032 in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:432
                            #8 0x7fd5d85dcaf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
                            #9 0x7fd5d85dd288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
                            #10 0x7fd5d85db2b5 in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:259
                            #11 0x7fd5d85dc813 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:611
                            #12 0x7fd5d85dd288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
                            #13 0x7fd5d85db9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                            #14 0x7fd5d85dca28 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:633
                            #15 0x7fd5d85dd288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
                            #16 0x7fd5d85db9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                            #17 0x7fd5d85dcaf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
                            #18 0x7fd5d85dd7d3 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:494
                            #19 0x7fd5d85db9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                            #20 0x7fd5d85ddd1f in ASN1_item_ex_d2i crypto/asn1/tasn_dec.c:124
                            #21 0x7fd5d85dde35 in ASN1_item_d2i crypto/asn1/tasn_dec.c:114
                            #22 0x7fd5d85a77e0 in ASN1_item_d2i_bio crypto/asn1/a_d2i_fp.c:69
                            #23 0x402845 in FuzzerTestOneInput fuzz/cms.c:43
                            #24 0x402bbb in testfile fuzz/test-corpus.c:182
                            #25 0x402626 in main fuzz/test-corpus.c:226
                            #26 0x7fd5d7c81f44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21f44)
                            #27 0x402706  (/home/ed/OPC/openssl/fuzz/cms-test+0x402706)

                        =================================================================
                        ==29625==ERROR: LeakSanitizer: detected memory leaks

                        Direct leak of 32 byte(s) in 1 object(s) allocated from:
                            #0 0x7fd5d8b8309f in __interceptor_malloc ../../../../gcc-trunk/libsanitizer/asan/asan_malloc_linux.cpp:69
                            #1 0x7fd5d87c2430 in CRYPTO_zalloc crypto/mem.c:230
                            #2 0x7fd5d889501f in OPENSSL_sk_new_reserve crypto/stack/stack.c:209
                            #3 0x7fd5d85dcbc3 in sk_ASN1_VALUE_new_null include/openssl/asn1t.h:928
                            #4 0x7fd5d85dcbc3 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:577
                            #5 0x7fd5d85dd288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
                            #6 0x7fd5d85db104 in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:178
                            #7 0x7fd5d85ddd1f in ASN1_item_ex_d2i crypto/asn1/tasn_dec.c:124
                            #8 0x7fd5d85dde35 in ASN1_item_d2i crypto/asn1/tasn_dec.c:114
                            #9 0x7fd5d88f86d9 in X509V3_EXT_d2i crypto/x509v3/v3_lib.c:142
                            #10 0x7fd5d88d6d3c in crl_set_issuers crypto/x509/x_crl.c:97
                            #11 0x7fd5d88d6d3c in crl_cb crypto/x509/x_crl.c:246
                            #12 0x7fd5d85dc032 in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:432
                            #13 0x7fd5d85dcaf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
                            #14 0x7fd5d85dd288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
                            #15 0x7fd5d85db2b5 in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:259
                            #16 0x7fd5d85dc813 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:611
                            #17 0x7fd5d85dd288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
                            #18 0x7fd5d85db9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                            #19 0x7fd5d85dca28 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:633
                            #20 0x7fd5d85dd288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
                            #21 0x7fd5d85db9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                            #22 0x7fd5d85dcaf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
                            #23 0x7fd5d85dd7d3 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:494
                            #24 0x7fd5d85db9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                            #25 0x7fd5d85ddd1f in ASN1_item_ex_d2i crypto/asn1/tasn_dec.c:124
                            #26 0x7fd5d85dde35 in ASN1_item_d2i crypto/asn1/tasn_dec.c:114
                            #27 0x7fd5d85a77e0 in ASN1_item_d2i_bio crypto/asn1/a_d2i_fp.c:69
                            #28 0x402845 in FuzzerTestOneInput fuzz/cms.c:43
                            #29 0x402bbb in testfile fuzz/test-corpus.c:182
                            #30 0x402626 in main fuzz/test-corpus.c:226
                            #31 0x7fd5d7c81f44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21f44)

                        SUMMARY: AddressSanitizer: 32 byte(s) leaked in 1 allocation(s).

                        Reviewed-by: Paul Dale <pauli@openssl.org>
                        Reviewed-by: Tomas Mraz <tomas@openssl.org>
                        (Merged from https://github.com/openssl/openssl/pull/18391)

                        (cherry picked from commit e9007e09792e3735d4973743634ff55d354fc7d8)

                    commit 4a28f8451fbc1848fd2d1b99203a7c75876123f6
                    Author: Bernd Edlinger <bernd.edlinger@hotmail.de>
                    Date:   Sun May 22 20:12:56 2022 +0200

                        Fix a crash in ssl_security_cert_chain

                        Prior to the crash there is an out of memory error
                        in X509_verify_cert which makes the chain NULL or
                        empty.  The error is ignored by ssl_add_cert_chain,
                        and ssl_security_cert_chain crashes due to the
                        unchecked null pointer.

                        This is reproducible with my error injection patch.

                        The test vector has been validated on the 1.1.1 branch
                        but the issue is of course identical in all branches.

                        $ ERROR_INJECT=1652848273 ../util/shlib_wrap.sh ./server-test ./corpora/server/47c8e933c4ec66fa3c309422283dfe0f31aafae8# ./corpora/server/47c8e933c4ec66fa3c309422283dfe0f31aafae8
                            #0 0x7f3a8f766eba in __sanitizer_print_stack_trace ../../../../gcc-trunk/libsanitizer/asan/asan_stack.cpp:87
                            #1 0x403ba4 in my_malloc fuzz/test-corpus.c:114
                            #2 0x7f3a8f39a430 in CRYPTO_zalloc crypto/mem.c:230
                            #3 0x7f3a8f46bd3b in sk_reserve crypto/stack/stack.c:180
                            #4 0x7f3a8f46bd3b in OPENSSL_sk_insert crypto/stack/stack.c:242
                            #5 0x7f3a8f4a4fd8 in sk_X509_push include/openssl/x509.h:99
                            #6 0x7f3a8f4a4fd8 in X509_verify_cert crypto/x509/x509_vfy.c:286
                            #7 0x7f3a8fed726e in ssl_add_cert_chain ssl/statem/statem_lib.c:959
                            #8 0x7f3a8fed726e in ssl3_output_cert_chain ssl/statem/statem_lib.c:1015
                            #9 0x7f3a8fee1c50 in tls_construct_server_certificate ssl/statem/statem_srvr.c:3812
                            #10 0x7f3a8feb8b0a in write_state_machine ssl/statem/statem.c:843
                            #11 0x7f3a8feb8b0a in state_machine ssl/statem/statem.c:443
                            #12 0x7f3a8fe84b3f in SSL_do_handshake ssl/ssl_lib.c:3718
                            #13 0x403202 in FuzzerTestOneInput fuzz/server.c:740
                            #14 0x40371b in testfile fuzz/test-corpus.c:182
                            #15 0x402856 in main fuzz/test-corpus.c:226
                            #16 0x7f3a8e859f44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21f44)
                            #17 0x402936  (/home/ed/OPC/openssl/fuzz/server-test+0x402936)

                        AddressSanitizer:DEADLYSIGNAL
                        =================================================================
                        ==8400==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000158 (pc 0x7f3a8f4d822f bp 0x7ffc39b76190 sp 0x7ffc39b760a0 T0)
                        ==8400==The signal is caused by a READ memory access.
                        ==8400==Hint: address points to the zero page.
                            #0 0x7f3a8f4d822f in x509v3_cache_extensions crypto/x509v3/v3_purp.c:386
                            #1 0x7f3a8f4d9d3a in X509_check_purpose crypto/x509v3/v3_purp.c:84
                            #2 0x7f3a8f4da02a in X509_get_extension_flags crypto/x509v3/v3_purp.c:921
                            #3 0x7f3a8feff7d2 in ssl_security_cert_sig ssl/t1_lib.c:2518
                            #4 0x7f3a8feff7d2 in ssl_security_cert ssl/t1_lib.c:2542
                            #5 0x7f3a8feffa03 in ssl_security_cert_chain ssl/t1_lib.c:2562
                            #6 0x7f3a8fed728d in ssl_add_cert_chain ssl/statem/statem_lib.c:963
                            #7 0x7f3a8fed728d in ssl3_output_cert_chain ssl/statem/statem_lib.c:1015
                            #8 0x7f3a8fee1c50 in tls_construct_server_certificate ssl/statem/statem_srvr.c:3812
                            #9 0x7f3a8feb8b0a in write_state_machine ssl/statem/statem.c:843
                            #10 0x7f3a8feb8b0a in state_machine ssl/statem/statem.c:443
                            #11 0x7f3a8fe84b3f in SSL_do_handshake ssl/ssl_lib.c:3718
                            #12 0x403202 in FuzzerTestOneInput fuzz/server.c:740
                            #13 0x40371b in testfile fuzz/test-corpus.c:182
                            #14 0x402856 in main fuzz/test-corpus.c:226
                            #15 0x7f3a8e859f44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21f44)
                            #16 0x402936  (/home/ed/OPC/openssl/fuzz/server-test+0x402936)

                        AddressSanitizer can not provide additional info.
                        SUMMARY: AddressSanitizer: SEGV crypto/x509v3/v3_purp.c:386 in x509v3_cache_extensions
                        ==8400==ABORTING

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

                        (cherry picked from commit dc0ef292f7df4ce0c49c64b47726a6768f9ac044)

                    commit 59b8eca400d9ea7b77dc98fe08a91bbfe35d025a
                    Author: Bernd Edlinger <bernd.edlinger@hotmail.de>
                    Date:   Sat May 21 15:41:46 2022 +0200

                        Fix a memory leak in X509_issuer_and_serial_hash

                        This is reproducible with my error injection patch:

                        $ ERROR_INJECT=1653267699 ../util/shlib_wrap.sh ./x509-test ./corpora/x509/5f4034ae85d6587dcad4da3e812e80f3d312894d
                        ERROR_INJECT=1653267699
                            #0 0x7fd485a6ad4f in __sanitizer_print_stack_trace ../../../../src/libsanitizer/asan/asan_stack.cc:36
                            #1 0x55c12d268724 in my_malloc fuzz/test-corpus.c:114
                            #2 0x7fd484f51a75 in CRYPTO_zalloc crypto/mem.c:230
                            #3 0x7fd484ed778d in EVP_DigestInit_ex crypto/evp/digest.c:139
                            #4 0x7fd4850a9849 in X509_issuer_and_serial_hash crypto/x509/x509_cmp.c:44
                            #5 0x55c12d268951 in FuzzerTestOneInput fuzz/x509.c:44
                            #6 0x55c12d268239 in testfile fuzz/test-corpus.c:182
                            #7 0x55c12d267c7f in main fuzz/test-corpus.c:226
                            #8 0x7fd483a42082 in __libc_start_main ../csu/libc-start.c:308
                            #9 0x55c12d267e5d in _start (/home/ed/OPCToolboxV5/Source/Core/OpenSSL/openssl/fuzz/x509-test+0x3e5d)

                        =================================================================
                        ==1058475==ERROR: LeakSanitizer: detected memory leaks

                        Direct leak of 268 byte(s) in 1 object(s) allocated from:
                            #0 0x7fd485a5dc3e in __interceptor_realloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:163
                            #1 0x7fd484d2eb9b in BUF_MEM_grow crypto/buffer/buffer.c:97
                            #2 0x7fd4850b2913 in X509_NAME_oneline crypto/x509/x509_obj.c:43
                            #3 0x7fd4850a982f in X509_issuer_and_serial_hash crypto/x509/x509_cmp.c:41
                            #4 0x55c12d268951 in FuzzerTestOneInput fuzz/x509.c:44
                            #5 0x55c12d268239 in testfile fuzz/test-corpus.c:182
                            #6 0x55c12d267c7f in main fuzz/test-corpus.c:226
                            #7 0x7fd483a42082 in __libc_start_main ../csu/libc-start.c:308

                        SUMMARY: AddressSanitizer: 268 byte(s) leaked in 1 allocation(s).

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

                    commit e4b84b7514e5cbcbfc80e31b4ce609c7584e14bb
                    Author: Bernd Edlinger <bernd.edlinger@hotmail.de>
                    Date:   Fri May 20 16:54:41 2022 +0200

                        Fix undefined behaviour in EC_GROUP_new_from_ecparameters

                        This happens for instance with
                        fuzz/corpora/asn1/65cf44e85614c62f10cf3b7a7184c26293a19e4a
                        and causes the OPENSSL_malloc below to choke on the
                        zero length allocation request.

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

                    commit 8e1ece20cdb4a584be5311370256c4e813c09826
                    Author: Bernd Edlinger <bernd.edlinger@hotmail.de>
                    Date:   Fri May 20 16:15:44 2022 +0200

                        Fix a memory leak in ec_key_simple_oct2priv

                        This is reproducible with my error injection patch:

                        $ ERROR_INJECT=1652710284 ../util/shlib_wrap.sh ./server-test ./corpora/server/4e48da8aecce6b9b58e8e4dbbf0523e6d2dd56dc
                        140587884632000:error:03078041:bignum routines:bn_expand_internal:malloc failure:crypto/bn/bn_lib.c:282:
                        140587884632000:error:10103003:elliptic curve routines:ec_key_simple_oct2priv:BN lib:crypto/ec/ec_key.c:662:
                        140587884632000:error:100DE08E:elliptic curve routines:old_ec_priv_decode:decode error:crypto/ec/ec_ameth.c:464:
                        140587884632000:error:0D0680A8:asn1 encoding routines:asn1_check_tlen:wrong tag:crypto/asn1/tasn_dec.c:1149:
                        140587884632000:error:0D07803A:asn1 encoding routines:asn1_item_embed_d2i:nested asn1 error:crypto/asn1/tasn_dec.c:309:Type=X509_ALGOR
                        140587884632000:error:0D08303A:asn1 encoding routines:asn1_template_noexp_d2i:nested asn1 error:crypto/asn1/tasn_dec.c:646:Field=pkeyalg, Type=PKCS8_PRIV_KEY_INFO
                        140587884632000:error:0907B00D:PEM routines:PEM_read_bio_PrivateKey:ASN1 lib:crypto/pem/pem_pkey.c:88:

                        =================================================================
                        ==19676==ERROR: LeakSanitizer: detected memory leaks

                        Direct leak of 24 byte(s) in 1 object(s) allocated from:
                            #0 0x7fdd2a6bb09f in __interceptor_malloc ../../../../gcc-trunk/libsanitizer/asan/asan_malloc_linux.cpp:69
                            #1 0x7fdd2a2fa430 in CRYPTO_zalloc crypto/mem.c:230
                            #2 0x7fdd2a15df11 in BN_new crypto/bn/bn_lib.c:246
                            #3 0x7fdd2a15df88 in BN_secure_new crypto/bn/bn_lib.c:257
                            #4 0x7fdd2a247390 in ec_key_simple_oct2priv crypto/ec/ec_key.c:655
                            #5 0x7fdd2a241fc5 in d2i_ECPrivateKey crypto/ec/ec_asn1.c:1030
                            #6 0x7fdd2a23dac5 in old_ec_priv_decode crypto/ec/ec_ameth.c:463
                            #7 0x7fdd2a109db7 in d2i_PrivateKey crypto/asn1/d2i_pr.c:46
                            #8 0x7fdd2a33ab16 in PEM_read_bio_PrivateKey crypto/pem/pem_pkey.c:84
                            #9 0x7fdd2a3330b6 in PEM_read_bio_ECPrivateKey crypto/pem/pem_all.c:151
                            #10 0x402dba in FuzzerTestOneInput fuzz/server.c:592
                            #11 0x40370b in testfile fuzz/test-corpus.c:182
                            #12 0x402846 in main fuzz/test-corpus.c:226
                            #13 0x7fdd297b9f44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21f44)

                        SUMMARY: AddressSanitizer: 24 byte(s) leaked in 1 allocation(s).

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

                    commit 8e60f41d064786f95440e4c56660ffe9777783d7
                    Author: Bernd Edlinger <bernd.edlinger@hotmail.de>
                    Date:   Fri May 20 08:02:47 2022 +0200

                        Fix a crash in asn1_item_embed_new

                        This happens usually if an template object is created
                        and there is an out of memory error before the ASN1_OP_NEW_POST
                        method is called, but asn1_item_embed_free calls now the
                        ASN1_OP_FREE_POST which may crash because the object is not
                        properly initialized.  Apparently that is only an issue with
                        the ASN1_OP_FREE_POST handling of crypot/x509/x_crl.c, which
                        ought to be tolerant to incomplete initialized objects.

                        The error can be reproduced with the reproducible error injection patch:

                        $ ERROR_INJECT=1652890550 ../util/shlib_wrap.sh ./asn1-test ./corpora/asn1/0ff17293911f54d1538b9896563a4048d67d9ee4
                            #0 0x7faae9dbeeba in __sanitizer_print_stack_trace ../../../../gcc-trunk/libsanitizer/asan/asan_stack.cpp:87
                            #1 0x408dc4 in my_malloc fuzz/test-corpus.c:114
                            #2 0x7faae99f2430 in CRYPTO_zalloc crypto/mem.c:230
                            #3 0x7faae97f09e5 in ASN1_STRING_type_new crypto/asn1/asn1_lib.c:341
                            #4 0x7faae98118f7 in asn1_primitive_new crypto/asn1/tasn_new.c:318
                            #5 0x7faae9812401 in asn1_item_embed_new crypto/asn1/tasn_new.c:78
                            #6 0x7faae9812401 in asn1_template_new crypto/asn1/tasn_new.c:240
                            #7 0x7faae9812315 in asn1_item_embed_new crypto/asn1/tasn_new.c:137
                            #8 0x7faae9812315 in asn1_template_new crypto/asn1/tasn_new.c:240
                            #9 0x7faae9812a54 in asn1_item_embed_new crypto/asn1/tasn_new.c:137
                            #10 0x7faae9812a54 in ASN1_item_ex_new crypto/asn1/tasn_new.c:39
                            #11 0x7faae980be51 in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:325
                            #12 0x7faae980c813 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:611
                            #13 0x7faae980d288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
                            #14 0x7faae980b9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                            #15 0x7faae980caf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
                            #16 0x7faae980d7d3 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:494
                            #17 0x7faae980b9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                            #18 0x7faae980dd1f in ASN1_item_ex_d2i crypto/asn1/tasn_dec.c:124
                            #19 0x7faae980de35 in ASN1_item_d2i crypto/asn1/tasn_dec.c:114
                            #20 0x40712c in FuzzerTestOneInput fuzz/asn1.c:301
                            #21 0x40893b in testfile fuzz/test-corpus.c:182
                            #22 0x406b86 in main fuzz/test-corpus.c:226
                            #23 0x7faae8eb1f44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21f44)

                        AddressSanitizer:DEADLYSIGNAL
                        =================================================================
                        ==1194==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000010 (pc 0x7faae9b0625f bp 0x7fffffe41a00 sp 0x7fffffe41920 T0)
                        ==1194==The signal is caused by a READ memory access.
                        ==1194==Hint: address points to the zero page.
                            #0 0x7faae9b0625f in crl_cb crypto/x509/x_crl.c:258
                            #1 0x7faae9811255 in asn1_item_embed_free crypto/asn1/tasn_fre.c:113
                            #2 0x7faae9812a65 in asn1_item_embed_new crypto/asn1/tasn_new.c:150
                            #3 0x7faae9812a65 in ASN1_item_ex_new crypto/asn1/tasn_new.c:39
                            #4 0x7faae980be51 in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:325
                            #5 0x7faae980c813 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:611
                            #6 0x7faae980d288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
                            #7 0x7faae980b9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                            #8 0x7faae980caf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
                            #9 0x7faae980d7d3 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:494
                            #10 0x7faae980b9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                            #11 0x7faae980dd1f in ASN1_item_ex_d2i crypto/asn1/tasn_dec.c:124
                            #12 0x7faae980de35 in ASN1_item_d2i crypto/asn1/tasn_dec.c:114
                            #13 0x40712c in FuzzerTestOneInput fuzz/asn1.c:301
                            #14 0x40893b in testfile fuzz/test-corpus.c:182
                            #15 0x406b86 in main fuzz/test-corpus.c:226
                            #16 0x7faae8eb1f44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21f44)

                        AddressSanitizer can not provide additional info.
                        SUMMARY: AddressSanitizer: SEGV crypto/x509/x_crl.c:258 in crl_cb
                        ==1194==ABORTING

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

                        (cherry picked from commit 557825acd622f98fc21423aba092e374db84f483)

                    commit 17519e2595b5ed8211a7763ff6eb2d6cf47c13cb
                    Author: Bernd Edlinger <bernd.edlinger@hotmail.de>
                    Date:   Thu May 19 15:50:28 2022 +0200

                        Backport a missing bug-fix from master

                        This is a backport of the following commit from master:

                        commit 61b0fead5e6079ca826594df5b9ca00e65883cb0
                        Author: Matt Caswell <matt@openssl.org>
                        Date:   Thu Nov 19 13:58:21 2020 +0000

                            Don't Overflow when printing Thawte Strong Extranet Version

                            When printing human readable info on the Thawte Strong Extranet extension
                            the version number could overflow if the version number == LONG_MAX. This
                            is undefined behaviour.

                            Issue found by OSSFuzz.

                            Reviewed-by: Ben Kaduk <kaduk@mit.edu>
                            (Merged from https://github.com/openssl/openssl/pull/13452)

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

                    commit 03ba56f1525c93eb3dfe72f85cdc698b97918e59
                    Author: Bernd Edlinger <bernd.edlinger@hotmail.de>
                    Date:   Thu May 19 10:59:25 2022 +0200

                        Backport some fuzzing data files from master

                        This is a backport of the following commit from master:

                        commit 415e6ac80405e13b20b083315747e431274fbd33
                        Author: Tavis Ormandy <taviso@gmail.com>
                        Date:   Tue Sep 21 15:48:27 2021 -0700

                            increase x509 code coverage metrics

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

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

                    commit e04ba889594d84a8805f3d0caeadf0527470e508
                    Author: Daniel Fiala <daniel@openssl.org>
                    Date:   Tue May 10 08:46:37 2022 +0000

                        s_serve: Report an error if init-connection fails without an attempt to read.

                        Fixes: openssl#18047.

                        Reviewed-by: Paul Dale <pauli@openssl.org>
                        Reviewed-by: Tomas Mraz <tomas@openssl.org>
                        (Merged from https://github.com/openssl/openssl/pull/18283)

                    commit 6ef91d8153e04a2302bff11b29caf7e888b62fe8
                    Author: basavesh <basavesh.shivakumar@gmail.com>
                    Date:   Tue Apr 5 17:49:09 2022 +0200

                        Fix leakage when the cacheline is 32-bytes in CBC_MAC_ROTATE_IN_PLACE

                        rotated_mac is a 64-byte aligned buffer of size 64 and rotate_offset is secret.
                        Consider a weaker leakage model(CL) where only cacheline base address is leaked,
                        i.e address/32 for 32-byte cacheline(CL32).

                        Previous code used to perform two loads
                            1. rotated_mac[rotate_offset ^ 32] and
                            2. rotated_mac[rotate_offset++]
                        which would leak 2q + 1, 2q for 0 <= rotate_offset < 32
                        and 2q, 2q + 1 for 32 <= rotate_offset < 64

                        The proposed fix performs load operations which will always leak 2q, 2q + 1 and
                        selects the appropriate value in constant-time.

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

                    commit c7d6c08290b67cbeef2b4f636f04788ea405520a
                    Author: Tomas Mraz <tomas@openssl.org>
                    Date:   Fri Apr 29 17:02:19 2022 +0200

                        Add test for empty supported-groups extension

                        Reviewed-by: Paul Dale <pauli@openssl.org>
                        Reviewed-by: Matt Caswell <matt@openssl.org>
                        (Merged from https://github.com/openssl/openssl/pull/18213)

                    commit bd164884f258d99ca876f6cdcdf9bd0dcceee6ad
                    Author: Tomas Mraz <tomas@openssl.org>
                    Date:   Fri Apr 29 16:36:36 2022 +0200

                        Do not send an empty supported groups extension

                        This allows handshake to proceed if the maximum TLS version enabled is <1.3

                        Fixes #13583

                        Reviewed-by: Paul Dale <pauli@openssl.org>
                        Reviewed-by: Matt Caswell <matt@openssl.org>
                        (Merged from https://github.com/openssl/openssl/pull/18213)

                    commit ac2d4cb656b3a796db3dc6f8873e91e67907372d
                    Author: Allan Jude <allan@klarasystems.com>
                    Date:   Fri Nov 19 19:06:52 2021 +0000

                        1_1_1-stable: Detect arm64-*-*bsd and enable assembly optimizations

                        Reviewed-by: Paul Dale <pauli@openssl.org>
                        Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
                        Reviewed-by: Tomas Mraz <tomas@openssl.org>
                        (Merged from https://github.com/openssl/openssl/pull/17085)

                    commit ec1b4bf26c1b2440546f323873c578374f60b2de
                    Author: Hugo Landau <hlandau@openssl.org>
                    Date:   Wed Apr 27 10:11:08 2022 +0100

                        (1.1) Add SSL_(CTX_)?get0_(verify|chain)_cert_store functions

                        Backport of #18038 to 1.1.

                        Fixes #18035.

                        Reviewed-by: Tomas Mraz <tomas@openssl.org>
                        Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
                        (Merged from https://github.com/openssl/openssl/pull/18190)

                    commit 988c7b2d9361dd0ade5ef7ef068fb4ed770ce2a2
                    Author: Matt Caswell <matt@openssl.org>
                    Date:   Tue May 3 14:41:23 2022 +0100

                        Prepare for 1.1.1p-dev

                        Reviewed-by: Tomas Mraz <tomas@openssl.org>
                        Release: yes

                commit 5ea6414f0bf861e8fece53b5bf35c849bad64774
                Author: Randall S. Becker <rsbecker@nexbridge.com>
                Date:   Wed Jun 22 06:26:40 2022 -0600

                    Squashed commit of the following:

                    commit 8aaca20cf9996257d1ce2e6f4d3059b3698dde3d
                    Author: Matt Caswell <matt@openssl.org>
                    Date:   Tue Jun 21 14:39:39 2022 +0100

                        Prepare for 1.1.1p release

                        Reviewed-by: Richard Levitte <levitte@openssl.org>
                        Release: yes

                    commit a3fc812c0c78e2f5db8b9d45bddaff62dfc958ae
                    Author: Matt Caswell <matt@openssl.org>
                    Date:   Tue Jun 21 14:07:32 2022 +0100

                        Update copyright year

                        Reviewed-by: Richard Levitte <levitte@openssl.org>
                        Release: yes

                    commit 51e06520734063d6f52b2e596e1089d36d3781e7
                    Author: Matt Caswell <matt@openssl.org>
                    Date:   Mon Jun 20 14:14:20 2022 +0100

                        Update CHANGES and NEWS for new release

                        Reviewed-by: Tomas Mraz <tomas@openssl.org>
                        Release: yes

                    commit 9639817dac8bbbaa64d09efad7464ccc405527c7
                    Author: Daniel Fiala <daniel@openssl.org>
                    Date:   Sun May 29 20:11:24 2022 +0200

                        Fix file operations in c_rehash.

                        CVE-2022-2068

                        Reviewed-by: Matt Caswell <matt@openssl.org>
                        Reviewed-by: Richard Levitte <levitte@openssl.org>

                    commit 20af01d46ca4086f6b1339b67c15c81d8b4a040d
                    Author: Fraser Tweedale <ftweedal@redhat.com>
                    Date:   Wed Jun 15 10:50:57 2022 +1000

                        Fix documentation of BIO_FLAGS_BASE64_NO_NL

                        Commit 8bfb7506d210841f2ee4eda8afe96441a0e33fa5 updated
                        `BIO_f_base64(3)` to improve the documentation of the
                        `BIO_FLAGS_BASE64_NO_NL` flag.  In particular, the updated text
                        states that when this flag is used, all newlines in the input are
                        ignored.  This is incorrect, as the following program proves:

                        ```c

                        unsigned char *in_buf =
                            "IlRoZSBxdWljayBicm93biBmb3gganVt\ncHMgb3ZlciBhIGxhenkgZG9nLiI=\n";

                        int main(int argc, char **argv) {
                            BIO *b64 = BIO_new(BIO_f_base64());
                            if (b64 == NULL) return 1;
                            BIO_set_flags(b64, BIO_get_flags(b64) | BIO_FLAGS_BASE64_NO_NL);
                            int in_len = strlen(in_buf);
                            BIO *in = BIO_new_mem_buf(in_buf, in_len);
                            if (in == NULL) return 2;
                            in = BIO_push(b64, in);
                            unsigned char *out_buf = calloc(in_len, sizeof(unsigned char));
                            if (out_buf == NULL) return 3;
                            size_t out_len;
                            int r = BIO_read_ex(in, out_buf, in_len, &out_len);
                            printf("rv = %d\n", r);
                            printf("decoded = %s\n", out_buf);
                            return 0;
                        }
                        ```

                        Update the text of `BIO_f_base64(3)` to clarify that when the flag
                        is set, the data must be all on one line (with or without a trailing
                        newline character).

                        Signed-off-by: Fraser Tweedale <ftweedal@redhat.com>

                        Reviewed-by: Paul Dale <pauli@openssl.org>
                        Reviewed-by: Tomas Mraz <tomas@openssl.org>
                        (Merged from https://github.com/openssl/openssl/pull/18568)

                        (cherry picked from commit 0edcbacca99ab2b716da395f204610fc2775ea83)

                    commit 8438d3a7b7309cbea521d3628fddeda7bd6d6e20
                    Author: Tomas Mraz <tomas@openssl.org>
                    Date:   Thu Jun 9 16:20:05 2022 +0200

                        Add an extra reduction step to RSAZ mod_exp implementations

                        Inspired by B…
bernd-edlinger added a commit to bernd-edlinger/openssl that referenced this pull request Aug 8, 2023
This can be reproduced with my error injection patch.

The test vector has been validated on the master branch:

$ ERROR_INJECT=1692279870 ../util/shlib_wrap.sh ./asn1parse-test ./corpora/asn1parse/027f6e82ba01d9db9a9167b83e56cc9f2c602550
ERROR_INJECT=1692279870
    #0 0x7f280b42fef8 in __sanitizer_print_stack_trace ../../../../src/libsanitizer/asan/asan_stack.cpp:86
    openssl#1 0x5610a3f396b4 in my_malloc fuzz/test-corpus.c:114
    openssl#2 0x7f280a2eb94c in CRYPTO_malloc crypto/mem.c:177
    openssl#3 0x7f280a2dafdb in OPENSSL_LH_insert crypto/lhash/lhash.c:114
    openssl#4 0x7f280a1c87fe in err_load_strings crypto/err/err.c:264
    openssl#5 0x7f280a1c87fe in err_load_strings crypto/err/err.c:259
    openssl#6 0x7f280a1c87fe in ERR_load_strings_const crypto/err/err.c:301
    openssl#7 0x7f280a6f513b in ossl_err_load_PROV_strings providers/common/provider_err.c:233
    openssl#8 0x7f280a1cf015 in ossl_err_load_crypto_strings crypto/err/err_all.c:109
    openssl#9 0x7f280a2e9b8c in ossl_init_load_crypto_strings crypto/init.c:190
    openssl#10 0x7f280a2e9b8c in ossl_init_load_crypto_strings_ossl_ crypto/init.c:181
    openssl#11 0x7f2808cfbf67  (/lib/x86_64-linux-gnu/libc.so.6+0x99f67)
    openssl#12 0x7f280a32301e in CRYPTO_THREAD_run_once crypto/threads_pthread.c:154
    openssl#13 0x7f280a2ea1da in OPENSSL_init_crypto crypto/init.c:553
    openssl#14 0x5610a3f38e2f in FuzzerInitialize fuzz/asn1parse.c:29
    openssl#15 0x5610a3f38783 in main fuzz/test-corpus.c:194
    openssl#16 0x7f2808c8bd8f  (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f)
    openssl#17 0x7f2808c8be3f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e3f)
    openssl#18 0x5610a3f38d34 in _start (/home/runner/work/openssl/openssl/fuzz/asn1parse-test+0x3d34)

AddressSanitizer:DEADLYSIGNAL
=================================================================
==27629==ERROR: AddressSanitizer: ABRT on unknown address 0x03e900006e23 (pc 0x7f2808cfbef8 bp 0x7f280b36afe0 sp 0x7ffd545b2460 T0)
    #0 0x7f2808cfbef8  (/lib/x86_64-linux-gnu/libc.so.6+0x99ef8)
    openssl#1 0x7f280a32301e in CRYPTO_THREAD_run_once crypto/threads_pthread.c:154
    openssl#2 0x7f280a2ea1da in OPENSSL_init_crypto crypto/init.c:553
    openssl#3 0x7f280a1c935e in ossl_err_get_state_int crypto/err/err.c:705
    openssl#4 0x7f280a1cf1f9 in ERR_new crypto/err/err_blocks.c:20
    openssl#5 0x7f280a2eb9ac in CRYPTO_malloc crypto/mem.c:205
    openssl#6 0x7f280a2dafdb in OPENSSL_LH_insert crypto/lhash/lhash.c:114
    openssl#7 0x7f280a1c87fe in err_load_strings crypto/err/err.c:264
    openssl#8 0x7f280a1c87fe in err_load_strings crypto/err/err.c:259
    openssl#9 0x7f280a1c87fe in ERR_load_strings_const crypto/err/err.c:301
    openssl#10 0x7f280a6f513b in ossl_err_load_PROV_strings providers/common/provider_err.c:233
    openssl#11 0x7f280a1cf015 in ossl_err_load_crypto_strings crypto/err/err_all.c:109
    openssl#12 0x7f280a2e9b8c in ossl_init_load_crypto_strings crypto/init.c:190
    openssl#13 0x7f280a2e9b8c in ossl_init_load_crypto_strings_ossl_ crypto/init.c:181
    openssl#14 0x7f2808cfbf67  (/lib/x86_64-linux-gnu/libc.so.6+0x99f67)
    openssl#15 0x7f280a32301e in CRYPTO_THREAD_run_once crypto/threads_pthread.c:154
    openssl#16 0x7f280a2ea1da in OPENSSL_init_crypto crypto/init.c:553
    openssl#17 0x5610a3f38e2f in FuzzerInitialize fuzz/asn1parse.c:29
    openssl#18 0x5610a3f38783 in main fuzz/test-corpus.c:194
    openssl#19 0x7f2808c8bd8f  (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f)
    openssl#20 0x7f2808c8be3f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e3f)
    openssl#21 0x5610a3f38d34 in _start (/home/runner/work/openssl/openssl/fuzz/asn1parse-test+0x3d34)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: ABRT (/lib/x86_64-linux-gnu/libc.so.6+0x99ef8)
==27629==ABORTING
bernd-edlinger added a commit to bernd-edlinger/openssl that referenced this pull request Aug 9, 2023
…STRINGS)

This can be reproduced with my error injection patch.

The test vector has been validated on the master branch:

$ ERROR_INJECT=1692279870 ../util/shlib_wrap.sh ./asn1parse-test ./corpora/asn1parse/027f6e82ba01d9db9a9167b83e56cc9f2c602550
ERROR_INJECT=1692279870
    #0 0x7f280b42fef8 in __sanitizer_print_stack_trace ../../../../src/libsanitizer/asan/asan_stack.cpp:86
    openssl#1 0x5610a3f396b4 in my_malloc fuzz/test-corpus.c:114
    openssl#2 0x7f280a2eb94c in CRYPTO_malloc crypto/mem.c:177
    openssl#3 0x7f280a2dafdb in OPENSSL_LH_insert crypto/lhash/lhash.c:114
    openssl#4 0x7f280a1c87fe in err_load_strings crypto/err/err.c:264
    openssl#5 0x7f280a1c87fe in err_load_strings crypto/err/err.c:259
    openssl#6 0x7f280a1c87fe in ERR_load_strings_const crypto/err/err.c:301
    openssl#7 0x7f280a6f513b in ossl_err_load_PROV_strings providers/common/provider_err.c:233
    openssl#8 0x7f280a1cf015 in ossl_err_load_crypto_strings crypto/err/err_all.c:109
    openssl#9 0x7f280a2e9b8c in ossl_init_load_crypto_strings crypto/init.c:190
    openssl#10 0x7f280a2e9b8c in ossl_init_load_crypto_strings_ossl_ crypto/init.c:181
    openssl#11 0x7f2808cfbf67  (/lib/x86_64-linux-gnu/libc.so.6+0x99f67)
    openssl#12 0x7f280a32301e in CRYPTO_THREAD_run_once crypto/threads_pthread.c:154
    openssl#13 0x7f280a2ea1da in OPENSSL_init_crypto crypto/init.c:553
    openssl#14 0x5610a3f38e2f in FuzzerInitialize fuzz/asn1parse.c:29
    openssl#15 0x5610a3f38783 in main fuzz/test-corpus.c:194
    openssl#16 0x7f2808c8bd8f  (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f)
    openssl#17 0x7f2808c8be3f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e3f)
    openssl#18 0x5610a3f38d34 in _start (/home/runner/work/openssl/openssl/fuzz/asn1parse-test+0x3d34)

AddressSanitizer:DEADLYSIGNAL
=================================================================
==27629==ERROR: AddressSanitizer: ABRT on unknown address 0x03e900006e23 (pc 0x7f2808cfbef8 bp 0x7f280b36afe0 sp 0x7ffd545b2460 T0)
    #0 0x7f2808cfbef8  (/lib/x86_64-linux-gnu/libc.so.6+0x99ef8)
    openssl#1 0x7f280a32301e in CRYPTO_THREAD_run_once crypto/threads_pthread.c:154
    openssl#2 0x7f280a2ea1da in OPENSSL_init_crypto crypto/init.c:553
    openssl#3 0x7f280a1c935e in ossl_err_get_state_int crypto/err/err.c:705
    openssl#4 0x7f280a1cf1f9 in ERR_new crypto/err/err_blocks.c:20
    openssl#5 0x7f280a2eb9ac in CRYPTO_malloc crypto/mem.c:205
    openssl#6 0x7f280a2dafdb in OPENSSL_LH_insert crypto/lhash/lhash.c:114
    openssl#7 0x7f280a1c87fe in err_load_strings crypto/err/err.c:264
    openssl#8 0x7f280a1c87fe in err_load_strings crypto/err/err.c:259
    openssl#9 0x7f280a1c87fe in ERR_load_strings_const crypto/err/err.c:301
    openssl#10 0x7f280a6f513b in ossl_err_load_PROV_strings providers/common/provider_err.c:233
    openssl#11 0x7f280a1cf015 in ossl_err_load_crypto_strings crypto/err/err_all.c:109
    openssl#12 0x7f280a2e9b8c in ossl_init_load_crypto_strings crypto/init.c:190
    openssl#13 0x7f280a2e9b8c in ossl_init_load_crypto_strings_ossl_ crypto/init.c:181
    openssl#14 0x7f2808cfbf67  (/lib/x86_64-linux-gnu/libc.so.6+0x99f67)
    openssl#15 0x7f280a32301e in CRYPTO_THREAD_run_once crypto/threads_pthread.c:154
    openssl#16 0x7f280a2ea1da in OPENSSL_init_crypto crypto/init.c:553
    openssl#17 0x5610a3f38e2f in FuzzerInitialize fuzz/asn1parse.c:29
    openssl#18 0x5610a3f38783 in main fuzz/test-corpus.c:194
    openssl#19 0x7f2808c8bd8f  (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f)
    openssl#20 0x7f2808c8be3f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e3f)
    openssl#21 0x5610a3f38d34 in _start (/home/runner/work/openssl/openssl/fuzz/asn1parse-test+0x3d34)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: ABRT (/lib/x86_64-linux-gnu/libc.so.6+0x99ef8)
==27629==ABORTING

try to move it to ossl_err_string_int() instead

do the fix in ERR_lib_error_string instead

try err_shelve_state instead

fixup! try err_shelve_state instead
bernd-edlinger added a commit to bernd-edlinger/openssl that referenced this pull request Aug 9, 2023
…STRINGS)

This can be reproduced with my error injection patch.

The test vector has been validated on the master branch:

$ ERROR_INJECT=1692279870 ../util/shlib_wrap.sh ./asn1parse-test ./corpora/asn1parse/027f6e82ba01d9db9a9167b83e56cc9f2c602550
ERROR_INJECT=1692279870
    #0 0x7f280b42fef8 in __sanitizer_print_stack_trace ../../../../src/libsanitizer/asan/asan_stack.cpp:86
    openssl#1 0x5610a3f396b4 in my_malloc fuzz/test-corpus.c:114
    openssl#2 0x7f280a2eb94c in CRYPTO_malloc crypto/mem.c:177
    openssl#3 0x7f280a2dafdb in OPENSSL_LH_insert crypto/lhash/lhash.c:114
    openssl#4 0x7f280a1c87fe in err_load_strings crypto/err/err.c:264
    openssl#5 0x7f280a1c87fe in err_load_strings crypto/err/err.c:259
    openssl#6 0x7f280a1c87fe in ERR_load_strings_const crypto/err/err.c:301
    openssl#7 0x7f280a6f513b in ossl_err_load_PROV_strings providers/common/provider_err.c:233
    openssl#8 0x7f280a1cf015 in ossl_err_load_crypto_strings crypto/err/err_all.c:109
    openssl#9 0x7f280a2e9b8c in ossl_init_load_crypto_strings crypto/init.c:190
    openssl#10 0x7f280a2e9b8c in ossl_init_load_crypto_strings_ossl_ crypto/init.c:181
    openssl#11 0x7f2808cfbf67  (/lib/x86_64-linux-gnu/libc.so.6+0x99f67)
    openssl#12 0x7f280a32301e in CRYPTO_THREAD_run_once crypto/threads_pthread.c:154
    openssl#13 0x7f280a2ea1da in OPENSSL_init_crypto crypto/init.c:553
    openssl#14 0x5610a3f38e2f in FuzzerInitialize fuzz/asn1parse.c:29
    openssl#15 0x5610a3f38783 in main fuzz/test-corpus.c:194
    openssl#16 0x7f2808c8bd8f  (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f)
    openssl#17 0x7f2808c8be3f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e3f)
    openssl#18 0x5610a3f38d34 in _start (/home/runner/work/openssl/openssl/fuzz/asn1parse-test+0x3d34)

AddressSanitizer:DEADLYSIGNAL
=================================================================
==27629==ERROR: AddressSanitizer: ABRT on unknown address 0x03e900006e23 (pc 0x7f2808cfbef8 bp 0x7f280b36afe0 sp 0x7ffd545b2460 T0)
    #0 0x7f2808cfbef8  (/lib/x86_64-linux-gnu/libc.so.6+0x99ef8)
    openssl#1 0x7f280a32301e in CRYPTO_THREAD_run_once crypto/threads_pthread.c:154
    openssl#2 0x7f280a2ea1da in OPENSSL_init_crypto crypto/init.c:553
    openssl#3 0x7f280a1c935e in ossl_err_get_state_int crypto/err/err.c:705
    openssl#4 0x7f280a1cf1f9 in ERR_new crypto/err/err_blocks.c:20
    openssl#5 0x7f280a2eb9ac in CRYPTO_malloc crypto/mem.c:205
    openssl#6 0x7f280a2dafdb in OPENSSL_LH_insert crypto/lhash/lhash.c:114
    openssl#7 0x7f280a1c87fe in err_load_strings crypto/err/err.c:264
    openssl#8 0x7f280a1c87fe in err_load_strings crypto/err/err.c:259
    openssl#9 0x7f280a1c87fe in ERR_load_strings_const crypto/err/err.c:301
    openssl#10 0x7f280a6f513b in ossl_err_load_PROV_strings providers/common/provider_err.c:233
    openssl#11 0x7f280a1cf015 in ossl_err_load_crypto_strings crypto/err/err_all.c:109
    openssl#12 0x7f280a2e9b8c in ossl_init_load_crypto_strings crypto/init.c:190
    openssl#13 0x7f280a2e9b8c in ossl_init_load_crypto_strings_ossl_ crypto/init.c:181
    openssl#14 0x7f2808cfbf67  (/lib/x86_64-linux-gnu/libc.so.6+0x99f67)
    openssl#15 0x7f280a32301e in CRYPTO_THREAD_run_once crypto/threads_pthread.c:154
    openssl#16 0x7f280a2ea1da in OPENSSL_init_crypto crypto/init.c:553
    openssl#17 0x5610a3f38e2f in FuzzerInitialize fuzz/asn1parse.c:29
    openssl#18 0x5610a3f38783 in main fuzz/test-corpus.c:194
    openssl#19 0x7f2808c8bd8f  (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f)
    openssl#20 0x7f2808c8be3f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e3f)
    openssl#21 0x5610a3f38d34 in _start (/home/runner/work/openssl/openssl/fuzz/asn1parse-test+0x3d34)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: ABRT (/lib/x86_64-linux-gnu/libc.so.6+0x99ef8)
==27629==ABORTING
bernd-edlinger added a commit to bernd-edlinger/openssl that referenced this pull request Aug 9, 2023
…STRINGS)

A recursive OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS) call
may happen if an out-of-memory error happens at the first callstack,
and the dead-lock happens at the second callstack, because ossl_err_get_state_int
calls OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS) although that
call is currently already executing.

At least on posix system this causes the process to freeze at this
point, and must be avoided whatever it takes.

The fix is using err_shelve_state around the critical region, which
makes ossl_err_get_state_int return early and not call the recursive
OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS).

This can be reproduced with my error injection patch.

The test vector has been validated on the master branch:

$ ERROR_INJECT=1692279870 ../util/shlib_wrap.sh ./asn1parse-test ./corpora/asn1parse/027f6e82ba01d9db9a9167b83e56cc9f2c602550
ERROR_INJECT=1692279870
    #0 0x7f280b42fef8 in __sanitizer_print_stack_trace ../../../../src/libsanitizer/asan/asan_stack.cpp:86
    openssl#1 0x5610a3f396b4 in my_malloc fuzz/test-corpus.c:114
    openssl#2 0x7f280a2eb94c in CRYPTO_malloc crypto/mem.c:177
    openssl#3 0x7f280a2dafdb in OPENSSL_LH_insert crypto/lhash/lhash.c:114
    openssl#4 0x7f280a1c87fe in err_load_strings crypto/err/err.c:264
    openssl#5 0x7f280a1c87fe in err_load_strings crypto/err/err.c:259
    openssl#6 0x7f280a1c87fe in ERR_load_strings_const crypto/err/err.c:301
    openssl#7 0x7f280a6f513b in ossl_err_load_PROV_strings providers/common/provider_err.c:233
    openssl#8 0x7f280a1cf015 in ossl_err_load_crypto_strings crypto/err/err_all.c:109
    openssl#9 0x7f280a2e9b8c in ossl_init_load_crypto_strings crypto/init.c:190
    openssl#10 0x7f280a2e9b8c in ossl_init_load_crypto_strings_ossl_ crypto/init.c:181
    openssl#11 0x7f2808cfbf67  (/lib/x86_64-linux-gnu/libc.so.6+0x99f67)
    openssl#12 0x7f280a32301e in CRYPTO_THREAD_run_once crypto/threads_pthread.c:154
    openssl#13 0x7f280a2ea1da in OPENSSL_init_crypto crypto/init.c:553
    openssl#14 0x5610a3f38e2f in FuzzerInitialize fuzz/asn1parse.c:29
    openssl#15 0x5610a3f38783 in main fuzz/test-corpus.c:194
    openssl#16 0x7f2808c8bd8f  (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f)
    openssl#17 0x7f2808c8be3f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e3f)
    openssl#18 0x5610a3f38d34 in _start (/home/runner/work/openssl/openssl/fuzz/asn1parse-test+0x3d34)

AddressSanitizer:DEADLYSIGNAL
=================================================================
==27629==ERROR: AddressSanitizer: ABRT on unknown address 0x03e900006e23 (pc 0x7f2808cfbef8 bp 0x7f280b36afe0 sp 0x7ffd545b2460 T0)
    #0 0x7f2808cfbef8  (/lib/x86_64-linux-gnu/libc.so.6+0x99ef8)
    openssl#1 0x7f280a32301e in CRYPTO_THREAD_run_once crypto/threads_pthread.c:154
    openssl#2 0x7f280a2ea1da in OPENSSL_init_crypto crypto/init.c:553
    openssl#3 0x7f280a1c935e in ossl_err_get_state_int crypto/err/err.c:705
    openssl#4 0x7f280a1cf1f9 in ERR_new crypto/err/err_blocks.c:20
    openssl#5 0x7f280a2eb9ac in CRYPTO_malloc crypto/mem.c:205
    openssl#6 0x7f280a2dafdb in OPENSSL_LH_insert crypto/lhash/lhash.c:114
    openssl#7 0x7f280a1c87fe in err_load_strings crypto/err/err.c:264
    openssl#8 0x7f280a1c87fe in err_load_strings crypto/err/err.c:259
    openssl#9 0x7f280a1c87fe in ERR_load_strings_const crypto/err/err.c:301
    openssl#10 0x7f280a6f513b in ossl_err_load_PROV_strings providers/common/provider_err.c:233
    openssl#11 0x7f280a1cf015 in ossl_err_load_crypto_strings crypto/err/err_all.c:109
    openssl#12 0x7f280a2e9b8c in ossl_init_load_crypto_strings crypto/init.c:190
    openssl#13 0x7f280a2e9b8c in ossl_init_load_crypto_strings_ossl_ crypto/init.c:181
    openssl#14 0x7f2808cfbf67  (/lib/x86_64-linux-gnu/libc.so.6+0x99f67)
    openssl#15 0x7f280a32301e in CRYPTO_THREAD_run_once crypto/threads_pthread.c:154
    openssl#16 0x7f280a2ea1da in OPENSSL_init_crypto crypto/init.c:553
    openssl#17 0x5610a3f38e2f in FuzzerInitialize fuzz/asn1parse.c:29
    openssl#18 0x5610a3f38783 in main fuzz/test-corpus.c:194
    openssl#19 0x7f2808c8bd8f  (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f)
    openssl#20 0x7f2808c8be3f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e3f)
    openssl#21 0x5610a3f38d34 in _start (/home/runner/work/openssl/openssl/fuzz/asn1parse-test+0x3d34)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: ABRT (/lib/x86_64-linux-gnu/libc.so.6+0x99ef8)
==27629==ABORTING
openssl-machine pushed a commit that referenced this pull request Aug 10, 2023
…STRINGS)

A recursive OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS) call
may happen if an out-of-memory error happens at the first callstack,
and the dead-lock happens at the second callstack, because ossl_err_get_state_int
calls OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS) although that
call is currently already executing.

At least on posix system this causes the process to freeze at this
point, and must be avoided whatever it takes.

The fix is using err_shelve_state around the critical region, which
makes ossl_err_get_state_int return early and not call the recursive
OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS).

This can be reproduced with my error injection patch.

The test vector has been validated on the master branch:

$ ERROR_INJECT=1692279870 ../util/shlib_wrap.sh ./asn1parse-test ./corpora/asn1parse/027f6e82ba01d9db9a9167b83e56cc9f2c602550
ERROR_INJECT=1692279870
    #0 0x7f280b42fef8 in __sanitizer_print_stack_trace ../../../../src/libsanitizer/asan/asan_stack.cpp:86
    #1 0x5610a3f396b4 in my_malloc fuzz/test-corpus.c:114
    #2 0x7f280a2eb94c in CRYPTO_malloc crypto/mem.c:177
    #3 0x7f280a2dafdb in OPENSSL_LH_insert crypto/lhash/lhash.c:114
    #4 0x7f280a1c87fe in err_load_strings crypto/err/err.c:264
    #5 0x7f280a1c87fe in err_load_strings crypto/err/err.c:259
    #6 0x7f280a1c87fe in ERR_load_strings_const crypto/err/err.c:301
    #7 0x7f280a6f513b in ossl_err_load_PROV_strings providers/common/provider_err.c:233
    #8 0x7f280a1cf015 in ossl_err_load_crypto_strings crypto/err/err_all.c:109
    #9 0x7f280a2e9b8c in ossl_init_load_crypto_strings crypto/init.c:190
    #10 0x7f280a2e9b8c in ossl_init_load_crypto_strings_ossl_ crypto/init.c:181
    #11 0x7f2808cfbf67  (/lib/x86_64-linux-gnu/libc.so.6+0x99f67)
    #12 0x7f280a32301e in CRYPTO_THREAD_run_once crypto/threads_pthread.c:154
    #13 0x7f280a2ea1da in OPENSSL_init_crypto crypto/init.c:553
    #14 0x5610a3f38e2f in FuzzerInitialize fuzz/asn1parse.c:29
    #15 0x5610a3f38783 in main fuzz/test-corpus.c:194
    #16 0x7f2808c8bd8f  (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f)
    #17 0x7f2808c8be3f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e3f)
    #18 0x5610a3f38d34 in _start (/home/runner/work/openssl/openssl/fuzz/asn1parse-test+0x3d34)

AddressSanitizer:DEADLYSIGNAL
=================================================================
==27629==ERROR: AddressSanitizer: ABRT on unknown address 0x03e900006e23 (pc 0x7f2808cfbef8 bp 0x7f280b36afe0 sp 0x7ffd545b2460 T0)
    #0 0x7f2808cfbef8  (/lib/x86_64-linux-gnu/libc.so.6+0x99ef8)
    #1 0x7f280a32301e in CRYPTO_THREAD_run_once crypto/threads_pthread.c:154
    #2 0x7f280a2ea1da in OPENSSL_init_crypto crypto/init.c:553
    #3 0x7f280a1c935e in ossl_err_get_state_int crypto/err/err.c:705
    #4 0x7f280a1cf1f9 in ERR_new crypto/err/err_blocks.c:20
    #5 0x7f280a2eb9ac in CRYPTO_malloc crypto/mem.c:205
    #6 0x7f280a2dafdb in OPENSSL_LH_insert crypto/lhash/lhash.c:114
    #7 0x7f280a1c87fe in err_load_strings crypto/err/err.c:264
    #8 0x7f280a1c87fe in err_load_strings crypto/err/err.c:259
    #9 0x7f280a1c87fe in ERR_load_strings_const crypto/err/err.c:301
    #10 0x7f280a6f513b in ossl_err_load_PROV_strings providers/common/provider_err.c:233
    #11 0x7f280a1cf015 in ossl_err_load_crypto_strings crypto/err/err_all.c:109
    #12 0x7f280a2e9b8c in ossl_init_load_crypto_strings crypto/init.c:190
    #13 0x7f280a2e9b8c in ossl_init_load_crypto_strings_ossl_ crypto/init.c:181
    #14 0x7f2808cfbf67  (/lib/x86_64-linux-gnu/libc.so.6+0x99f67)
    #15 0x7f280a32301e in CRYPTO_THREAD_run_once crypto/threads_pthread.c:154
    #16 0x7f280a2ea1da in OPENSSL_init_crypto crypto/init.c:553
    #17 0x5610a3f38e2f in FuzzerInitialize fuzz/asn1parse.c:29
    #18 0x5610a3f38783 in main fuzz/test-corpus.c:194
    #19 0x7f2808c8bd8f  (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f)
    #20 0x7f2808c8be3f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e3f)
    #21 0x5610a3f38d34 in _start (/home/runner/work/openssl/openssl/fuzz/asn1parse-test+0x3d34)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: ABRT (/lib/x86_64-linux-gnu/libc.so.6+0x99ef8)
==27629==ABORTING

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from #21683)
rsbeckerca added a commit to ituglib/openssl that referenced this pull request Sep 11, 2023
Squashed commit of the following:

commit ec67064bdce4af6b490ea542a028046aaaaf014e
Author: Randall S. Becker <randall.becker@nexbridge.ca>
Date:   Tue Aug 1 23:36:20 2023 +0100

    Merged OpenSSL 1.1.1v with ituglib_release

    commit 84ef302bbb2c1bb9a3c10abfd31984e2a8731e7f
    Author: Randall S. Becker <rsbecker@nexbridge.com>
    Date:   Tue May 30 08:30:00 2023 -0600

        Merged OpenSSL 1.1.1u with ituglib_release

        commit 65be16881b71f4d66c77664775c93340a7b89c6d
        Author: Randall S. Becker <rsbecker@nexbridge.com>
        Date:   Tue Feb 7 09:13:22 2023 -0700

            Squashed commit of the following:

            commit 44ea69d6aadbbf9b951335e5ed296eed019e9ffe
            Author: Randall S. Becker <rsbecker@nexbridge.com>
            Date:   Wed Nov 2 12:49:30 2022 -0600

                Squashed commit of the following:

                commit 1b3fb89163127047b0f99412b8a31522215b3bea
                Author: Randall S. Becker <rsbecker@nexbridge.com>
                Date:   Tue Oct 11 11:17:39 2022 -0600

                    Squashed commit of the following:

                    commit 6fd6179191702eb0562ccbfb22a37405c669b90e
                    Author: Randall S. Becker <randall.becker@nexbridge.ca>
                    Date:   Tue Jul 5 17:50:13 2022 -0400

                        Missed include on NonStop for memcmp in test/v3ext.c

                    commit d97281f16602e50f040756029b555645315253df
                    Author: Randall S. Becker <randall.becker@nexbridge.ca>
                    Date:   Tue Jul 5 10:37:54 2022 -0400

                        Squashed commit of the following:

                        commit 29708a562a1887a91de0fa6ca668c71871accde9
                        Author: Richard Levitte <levitte@openssl.org>
                        Date:   Tue Jul 5 11:08:33 2022 +0200

                            Prepare for 1.1.1q release

                            Reviewed-by: Paul Dale <pauli@openssl.org>
                            Release: yes

                        commit 95a17c0ead00885452d13309eaffd04c1737d05d
                        Author: Richard Levitte <levitte@openssl.org>
                        Date:   Tue Jul 5 10:33:00 2022 +0200

                            Update copyright year

                            Reviewed-by: Paul Dale <pauli@openssl.org>
                            Release: yes

                        commit 78ba51a3b8b505d8d03abca8fa95e4fb1464d94e
                        Author: Richard Levitte <levitte@openssl.org>
                        Date:   Tue Jul 5 10:25:00 2022 +0200

                            Update CHANGES and NEWS for upcoming release 1.1.1q

                            Reviewed-by: Paul Dale <pauli@openssl.org>
                            Release: yes

                        commit 9131afdca30b6d1650af9ea6179569a80ab8cb06
                        Author: Alex Chernyakhovsky <achernya@google.com>
                        Date:   Thu Jun 16 12:02:37 2022 +1000

                            AES OCB test vectors

                            Add test vectors for AES OCB for x86 AES-NI multiple of 96 byte issue.

                            Co-authored-by: Alejandro Sedeño <asedeno@google.com>
                            Co-authored-by: David Benjamin <davidben@google.com>

                            Reviewed-by: Paul Dale <pauli@openssl.org>
                            Reviewed-by: Tomas Mraz <tomas@openssl.org>

                        commit 919925673d6c9cfed3c1085497f5dfbbed5fc431
                        Author: Alex Chernyakhovsky <achernya@google.com>
                        Date:   Thu Jun 16 12:00:22 2022 +1000

                            Fix AES OCB encrypt/decrypt for x86 AES-NI

                            aesni_ocb_encrypt and aesni_ocb_decrypt operate by having a fast-path
                            that performs operations on 6 16-byte blocks concurrently (the
                            "grandloop") and then proceeds to handle the "short" tail (which can
                            be anywhere from 0 to 5 blocks) that remain.

                            As part of initialization, the assembly initializes $len to the true
                            length, less 96 bytes and converts it to a pointer so that the $inp
                            can be compared to it. Each iteration of "grandloop" checks to see if
                            there's a full 96-byte chunk to process, and if so, continues. Once
                            this has been exhausted, it falls through to "short", which handles
                            the remaining zero to five blocks.

                            Unfortunately, the jump at the end of "grandloop" had a fencepost
                            error, doing a `jb` ("jump below") rather than `jbe` (jump below or
                            equal). This should be `jbe`, as $inp is pointing to the *end* of the
                            chunk currently being handled. If $inp == $len, that means that
                            there's a whole 96-byte chunk waiting to be handled. If $inp > $len,
                            then there's 5 or fewer 16-byte blocks left to be handled, and the
                            fall-through is intended.

                            The net effect of `jb` instead of `jbe` is that the last 16-byte block
                            of the last 96-byte chunk was completely omitted. The contents of
                            `out` in this position were never written to. Additionally, since
                            those bytes were never processed, the authentication tag generated is
                            also incorrect.

                            The same fencepost error, and identical logic, exists in both
                            aesni_ocb_encrypt and aesni_ocb_decrypt.

                            This addresses CVE-2022-2097.

                            Co-authored-by: Alejandro Sedeño <asedeno@google.com>
                            Co-authored-by: David Benjamin <davidben@google.com>

                            Reviewed-by: Paul Dale <pauli@openssl.org>
                            Reviewed-by: Tomas Mraz <tomas@openssl.org>

                        commit 6495cab1c876ad80ce983d848ccaa1dc286a63e1
                        Author: slontis <shane.lontis@oracle.com>
                        Date:   Fri Jul 1 13:47:11 2022 +1000

                            Fix bn_gcd code to check return value when calling BN_one()

                            BN_one() uses the expand function which calls malloc which may fail.
                            All other places that reference BN_one() check the return value.

                            The issue is triggered by a memory allocation failure.
                            Detected by PR #18355

                            Reviewed-by: Tomas Mraz <tomas@openssl.org>
                            Reviewed-by: Paul Dale <pauli@openssl.org>
                            (Merged from https://github.com/openssl/openssl/pull/18697)

                            (cherry picked from commit 7fe7cc57af3db1e497877f0329ba17609b2efc8b)

                        commit 7a05fcb1fc276a7ecfe599d45655d4e617c5e2d4
                        Author: xkernel <xkernel.wang@foxmail.com>
                        Date:   Mon Jun 20 17:46:39 2022 +0800

                            v3_sxnet: add a check for the return of i2s_ASN1_INTEGER()

                            Reviewed-by: Matt Caswell <matt@openssl.org>
                            Reviewed-by: Ben Kaduk <kaduk@mit.edu>
                            (Merged from https://github.com/openssl/openssl/pull/18608)

                            (cherry picked from commit 9ef1f848a646565d4dd86e56542cf921d4921ad9)

                        commit a1d80edcf830739131e0567dc03b1e80b7988b1e
                        Author: Matt Caswell <matt@openssl.org>
                        Date:   Fri Jun 10 15:58:58 2022 +0100

                            Fix range_should_be_prefix() to actually return the correct result

                            range_should_be_prefix() was misidentifying whether an IP address range
                            should in fact be represented as a prefix. This was due to a bug introduced
                            in commit 42d7d7dd which made this incorrect change:

                            -    OPENSSL_assert(memcmp(min, max, length) <= 0);
                            +    if (memcmp(min, max, length) <= 0)
                            +        return -1;

                            This error leads to incorrect DER being encoded/accepted.

                            Reported by Theo Buehler (@botovq)

                            Reviewed-by: Paul Dale <pauli@openssl.org>
                            Reviewed-by: Tomas Mraz <tomas@openssl.org>
                            (Merged from https://github.com/openssl/openssl/pull/18524)

                            (cherry picked from commit 30532e59f475e0066c030693e4d614311a9e0cae)
                            (cherry picked from commit 2c6550c6db9b1b69dc24f968b4ceb534edcf4841)

                        commit 4c1cf6d39bb8e85658ac8c743dcff8ede730f76a
                        Author: Bernd Edlinger <bernd.edlinger@hotmail.de>
                        Date:   Fri Jun 17 10:25:24 2022 +0200

                            Fix compile issues in test/v3ext.c with no-rfc3779

                            There are no ASIdentifiers if OPENSSL_NO_RFC3779 is defined,
                            therefore the test cannot be compiled.

                            Reviewed-by: Matt Caswell <matt@openssl.org>
                            Reviewed-by: Tomas Mraz <tomas@openssl.org>
                            Reviewed-by: Paul Dale <pauli@openssl.org>
                            (Merged from https://github.com/openssl/openssl/pull/18634)

                            (cherry picked from commit b76efe61ea9710a8f69e1cb8caf1aeb2ba6f1ebe)
                            (cherry picked from commit 665ab12ed3f0d78e7cb6a55cdd2b83a2fe150232)

                        commit 882573246695088d65956355ca6c954642dcac31
                        Author: olszomal <Malgorzata.Olszowka@stunnel.org>
                        Date:   Fri Jun 17 15:01:11 2022 +0200

                            SSL_get_current_cipher() and SSL_get_pending_cipher() return 'const SSL_CIPHER *'

                            Fix the documentation.

                            CLA: trivial

                            Reviewed-by: Matt Caswell <matt@openssl.org>
                            Reviewed-by: Todd Short <todd.short@me.com>
                            Reviewed-by: Paul Dale <pauli@openssl.org>
                            Reviewed-by: Tomas Mraz <tomas@openssl.org>
                            (Merged from https://github.com/openssl/openssl/pull/18599)

                            (cherry picked from commit d842b6eff0940b6ce337536cb718a8d561290f50)

                        commit 6c8879c8bf6030666c851623f93fff03c1266715
                        Author: Bernd Edlinger <bernd.edlinger@hotmail.de>
                        Date:   Wed Jun 22 17:05:55 2022 +0200

                            Fix a memory leak in EC_GROUP_new_from_ecparameters

                            This can be reproduced with my error injection patch.

                            The test vector has been validated on the 1.1.1 branch
                            but the issue is of course identical in all branches.

                            $ ERROR_INJECT=1656112173 ../util/shlib_wrap.sh ./x509-test ./corpora/x509/fe543a8d7e09109a9a08114323eefec802ad79e2
                                #0 0x7fb61945eeba in __sanitizer_print_stack_trace ../../../../gcc-trunk/libsanitizer/asan/asan_stack.cpp:87
                                #1 0x402f84 in my_malloc fuzz/test-corpus.c:114
                                #2 0x7fb619092430 in CRYPTO_zalloc crypto/mem.c:230
                                #3 0x7fb618ef7561 in bn_expand_internal crypto/bn/bn_lib.c:280
                                #4 0x7fb618ef7561 in bn_expand2 crypto/bn/bn_lib.c:304
                                #5 0x7fb618ef819d in BN_bin2bn crypto/bn/bn_lib.c:454
                                #6 0x7fb618e7aa13 in asn1_string_to_bn crypto/asn1/a_int.c:503
                                #7 0x7fb618e7aa13 in ASN1_INTEGER_to_BN crypto/asn1/a_int.c:559
                                #8 0x7fb618fd8e79 in EC_GROUP_new_from_ecparameters crypto/ec/ec_asn1.c:814
                                #9 0x7fb618fd98e8 in EC_GROUP_new_from_ecpkparameters crypto/ec/ec_asn1.c:935
                                #10 0x7fb618fd9aec in d2i_ECPKParameters crypto/ec/ec_asn1.c:966
                                #11 0x7fb618fdace9 in d2i_ECParameters crypto/ec/ec_asn1.c:1184
                                #12 0x7fb618fd1fc7 in eckey_type2param crypto/ec/ec_ameth.c:119
                                #13 0x7fb618fd57b4 in eckey_pub_decode crypto/ec/ec_ameth.c:165
                                #14 0x7fb6191a9c62 in x509_pubkey_decode crypto/x509/x_pubkey.c:124
                                #15 0x7fb6191a9e42 in pubkey_cb crypto/x509/x_pubkey.c:46
                                #16 0x7fb618eac032 in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:432
                                #17 0x7fb618eacaf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
                                #18 0x7fb618ead288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
                                #19 0x7fb618eab9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                                #20 0x7fb618eacaf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
                                #21 0x7fb618ead288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
                                #22 0x7fb618eab9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                                #23 0x7fb618eadd1f in ASN1_item_ex_d2i crypto/asn1/tasn_dec.c:124
                                #24 0x7fb618eade35 in ASN1_item_d2i crypto/asn1/tasn_dec.c:114
                                #25 0x40310c in FuzzerTestOneInput fuzz/x509.c:33
                                #26 0x402afb in testfile fuzz/test-corpus.c:182
                                #27 0x402656 in main fuzz/test-corpus.c:226
                                #28 0x7fb618551f44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21f44)
                                #29 0x402756  (/home/ed/OPC/openssl/fuzz/x509-test+0x402756)

                            =================================================================
                            ==12221==ERROR: LeakSanitizer: detected memory leaks

                            Direct leak of 24 byte(s) in 1 object(s) allocated from:
                                #0 0x7fb61945309f in __interceptor_malloc ../../../../gcc-trunk/libsanitizer/asan/asan_malloc_linux.cpp:69
                                #1 0x7fb619092430 in CRYPTO_zalloc crypto/mem.c:230
                                #2 0x7fb618ef5f11 in BN_new crypto/bn/bn_lib.c:246
                                #3 0x7fb618ef82f4 in BN_bin2bn crypto/bn/bn_lib.c:440
                                #4 0x7fb618fd8933 in EC_GROUP_new_from_ecparameters crypto/ec/ec_asn1.c:618
                                #5 0x7fb618fd98e8 in EC_GROUP_new_from_ecpkparameters crypto/ec/ec_asn1.c:935
                                #6 0x7fb618fd9aec in d2i_ECPKParameters crypto/ec/ec_asn1.c:966
                                #7 0x7fb618fdace9 in d2i_ECParameters crypto/ec/ec_asn1.c:1184
                                #8 0x7fb618fd1fc7 in eckey_type2param crypto/ec/ec_ameth.c:119
                                #9 0x7fb618fd57b4 in eckey_pub_decode crypto/ec/ec_ameth.c:165
                                #10 0x7fb6191a9c62 in x509_pubkey_decode crypto/x509/x_pubkey.c:124
                                #11 0x7fb6191a9e42 in pubkey_cb crypto/x509/x_pubkey.c:46
                                #12 0x7fb618eac032 in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:432
                                #13 0x7fb618eacaf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
                                #14 0x7fb618ead288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
                                #15 0x7fb618eab9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                                #16 0x7fb618eacaf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
                                #17 0x7fb618ead288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
                                #18 0x7fb618eab9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                                #19 0x7fb618eadd1f in ASN1_item_ex_d2i crypto/asn1/tasn_dec.c:124
                                #20 0x7fb618eade35 in ASN1_item_d2i crypto/asn1/tasn_dec.c:114
                                #21 0x40310c in FuzzerTestOneInput fuzz/x509.c:33
                                #22 0x402afb in testfile fuzz/test-corpus.c:182
                                #23 0x402656 in main fuzz/test-corpus.c:226
                                #24 0x7fb618551f44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21f44)

                            Indirect leak of 56 byte(s) in 1 object(s) allocated from:
                                #0 0x7fb61945309f in __interceptor_malloc ../../../../gcc-trunk/libsanitizer/asan/asan_malloc_linux.cpp:69
                                #1 0x7fb619092430 in CRYPTO_zalloc crypto/mem.c:230
                                #2 0x7fb618ef7561 in bn_expand_internal crypto/bn/bn_lib.c:280
                                #3 0x7fb618ef7561 in bn_expand2 crypto/bn/bn_lib.c:304
                                #4 0x7fb618ef819d in BN_bin2bn crypto/bn/bn_lib.c:454
                                #5 0x7fb618fd8933 in EC_GROUP_new_from_ecparameters crypto/ec/ec_asn1.c:618
                                #6 0x7fb618fd98e8 in EC_GROUP_new_from_ecpkparameters crypto/ec/ec_asn1.c:935
                                #7 0x7fb618fd9aec in d2i_ECPKParameters crypto/ec/ec_asn1.c:966
                                #8 0x7fb618fdace9 in d2i_ECParameters crypto/ec/ec_asn1.c:1184
                                #9 0x7fb618fd1fc7 in eckey_type2param crypto/ec/ec_ameth.c:119
                                #10 0x7fb618fd57b4 in eckey_pub_decode crypto/ec/ec_ameth.c:165
                                #11 0x7fb6191a9c62 in x509_pubkey_decode crypto/x509/x_pubkey.c:124
                                #12 0x7fb6191a9e42 in pubkey_cb crypto/x509/x_pubkey.c:46
                                #13 0x7fb618eac032 in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:432
                                #14 0x7fb618eacaf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
                                #15 0x7fb618ead288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
                                #16 0x7fb618eab9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                                #17 0x7fb618eacaf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
                                #18 0x7fb618ead288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
                                #19 0x7fb618eab9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                                #20 0x7fb618eadd1f in ASN1_item_ex_d2i crypto/asn1/tasn_dec.c:124
                                #21 0x7fb618eade35 in ASN1_item_d2i crypto/asn1/tasn_dec.c:114
                                #22 0x40310c in FuzzerTestOneInput fuzz/x509.c:33
                                #23 0x402afb in testfile fuzz/test-corpus.c:182
                                #24 0x402656 in main fuzz/test-corpus.c:226
                                #25 0x7fb618551f44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21f44)

                            SUMMARY: AddressSanitizer: 80 byte(s) leaked in 2 allocation(s).

                            Reviewed-by: Tomas Mraz <tomas@openssl.org>
                            Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
                            (Merged from https://github.com/openssl/openssl/pull/18632)

                        commit 7f77ecd2facbd9df62ed727fbd1f522376d44bd3
                        Author: Matt Caswell <matt@openssl.org>
                        Date:   Tue Jun 21 14:39:48 2022 +0100

                            Prepare for 1.1.1q-dev

                            Reviewed-by: Richard Levitte <levitte@openssl.org>
                            Release: yes

                        commit 8aaca20cf9996257d1ce2e6f4d3059b3698dde3d
                        Author: Matt Caswell <matt@openssl.org>
                        Date:   Tue Jun 21 14:39:39 2022 +0100

                            Prepare for 1.1.1p release

                            Reviewed-by: Richard Levitte <levitte@openssl.org>
                            Release: yes

                        commit a3fc812c0c78e2f5db8b9d45bddaff62dfc958ae
                        Author: Matt Caswell <matt@openssl.org>
                        Date:   Tue Jun 21 14:07:32 2022 +0100

                            Update copyright year

                            Reviewed-by: Richard Levitte <levitte@openssl.org>
                            Release: yes

                        commit 51e06520734063d6f52b2e596e1089d36d3781e7
                        Author: Matt Caswell <matt@openssl.org>
                        Date:   Mon Jun 20 14:14:20 2022 +0100

                            Update CHANGES and NEWS for new release

                            Reviewed-by: Tomas Mraz <tomas@openssl.org>
                            Release: yes

                        commit 9639817dac8bbbaa64d09efad7464ccc405527c7
                        Author: Daniel Fiala <daniel@openssl.org>
                        Date:   Sun May 29 20:11:24 2022 +0200

                            Fix file operations in c_rehash.

                            CVE-2022-2068

                            Reviewed-by: Matt Caswell <matt@openssl.org>
                            Reviewed-by: Richard Levitte <levitte@openssl.org>

                        commit 20af01d46ca4086f6b1339b67c15c81d8b4a040d
                        Author: Fraser Tweedale <ftweedal@redhat.com>
                        Date:   Wed Jun 15 10:50:57 2022 +1000

                            Fix documentation of BIO_FLAGS_BASE64_NO_NL

                            Commit 8bfb7506d210841f2ee4eda8afe96441a0e33fa5 updated
                            `BIO_f_base64(3)` to improve the documentation of the
                            `BIO_FLAGS_BASE64_NO_NL` flag.  In particular, the updated text
                            states that when this flag is used, all newlines in the input are
                            ignored.  This is incorrect, as the following program proves:

                            ```c

                            unsigned char *in_buf =
                                "IlRoZSBxdWljayBicm93biBmb3gganVt\ncHMgb3ZlciBhIGxhenkgZG9nLiI=\n";

                            int main(int argc, char **argv) {
                                BIO *b64 = BIO_new(BIO_f_base64());
                                if (b64 == NULL) return 1;
                                BIO_set_flags(b64, BIO_get_flags(b64) | BIO_FLAGS_BASE64_NO_NL);
                                int in_len = strlen(in_buf);
                                BIO *in = BIO_new_mem_buf(in_buf, in_len);
                                if (in == NULL) return 2;
                                in = BIO_push(b64, in);
                                unsigned char *out_buf = calloc(in_len, sizeof(unsigned char));
                                if (out_buf == NULL) return 3;
                                size_t out_len;
                                int r = BIO_read_ex(in, out_buf, in_len, &out_len);
                                printf("rv = %d\n", r);
                                printf("decoded = %s\n", out_buf);
                                return 0;
                            }
                            ```

                            Update the text of `BIO_f_base64(3)` to clarify that when the flag
                            is set, the data must be all on one line (with or without a trailing
                            newline character).

                            Signed-off-by: Fraser Tweedale <ftweedal@redhat.com>

                            Reviewed-by: Paul Dale <pauli@openssl.org>
                            Reviewed-by: Tomas Mraz <tomas@openssl.org>
                            (Merged from https://github.com/openssl/openssl/pull/18568)

                            (cherry picked from commit 0edcbacca99ab2b716da395f204610fc2775ea83)

                        commit 8438d3a7b7309cbea521d3628fddeda7bd6d6e20
                        Author: Tomas Mraz <tomas@openssl.org>
                        Date:   Thu Jun 9 16:20:05 2022 +0200

                            Add an extra reduction step to RSAZ mod_exp implementations

                            Inspired by BoringSSL fix by David Benjamin.

                            Reviewed-by: Matt Caswell <matt@openssl.org>
                            Reviewed-by: Paul Dale <pauli@openssl.org>
                            (Merged from https://github.com/openssl/openssl/pull/18511)

                        commit 0ed27fb7a8d85685cb671bf0a1e41bcdfc2624dc
                        Author: Tomas Mraz <tomas@openssl.org>
                        Date:   Thu Jun 9 12:34:55 2022 +0200

                            Always end BN_mod_exp_mont_consttime with normal Montgomery reduction.

                            This partially fixes a bug where, on x86_64, BN_mod_exp_mont_consttime
                            would sometimes return m, the modulus, when it should have returned
                            zero. Thanks to Guido Vranken for reporting it. It is only a partial fix
                            because the same bug also exists in the "rsaz" codepath.

                            The bug only affects zero outputs (with non-zero inputs), so we believe
                            it has no security impact on our cryptographic functions.

                            The fx is to delete lowercase bn_from_montgomery altogether, and have the
                            mont5 path use the same BN_from_montgomery ending as the non-mont5 path.
                            This only impacts the final step of the whole exponentiation and has no
                            measurable perf impact.

                            See the original BoringSSL commit
                            https://boringssl.googlesource.com/boringssl/+/13c9d5c69d04485a7a8840c12185c832026c8315
                            for further analysis.

                            Original-author: David Benjamin <davidben@google.com>

                            Reviewed-by: Matt Caswell <matt@openssl.org>
                            Reviewed-by: Paul Dale <pauli@openssl.org>
                            (Merged from https://github.com/openssl/openssl/pull/18511)

                        commit 8f078819556da83c15751678c39558a59bc746fc
                        Author: Matt Caswell <matt@openssl.org>
                        Date:   Thu Jun 9 16:57:30 2022 +0100

                            Fix a crash in X509v3_asid_subset()

                            If the asnum or rdi fields are NULL and the ASIdentifiers are otherwise
                            subsets then this will result in a crash. Of note is that rdi will usually
                            be NULL.

                            Reported by Theo Buehler (@botovq)

                            Reviewed-by: Tomas Mraz <tomas@openssl.org>
                            Reviewed-by: Paul Yang <kaishen.yy@antfin.com>
                            Reviewed-by: Todd Short <todd.short@me.com>
                            (Merged from https://github.com/openssl/openssl/pull/18514)

                            (cherry picked from commit 01fc9b6bce82f0534d6673659a0e59a71f57ee82)

                        commit ab7d05617a444cfcf4f930f81caa4cf66495ab9b
                        Author: Tomas Mraz <tomas@openssl.org>
                        Date:   Thu Jun 2 18:12:05 2022 +0200

                            Update further expiring certificates that affect tests

                            Namely the smime certificates used in test_cms
                            will expire soon and affect tests.

                            Fixes #15179

                            Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
                            Reviewed-by: Paul Dale <pauli@openssl.org>
                            (Merged from https://github.com/openssl/openssl/pull/18481)

                        commit 3bd976551e549c030bdbd150c7aa8a1980cb00fe
                        Author: Tomas Mraz <tomas@openssl.org>
                        Date:   Tue Mar 29 13:31:34 2022 +0200

                            Fix strict client chain check with TLS-1.3

                            When TLS-1.3 is used and the server does not send any CA names
                            the ca_dn will be NULL. sk_X509_NAME_num() returns -1 on null
                            argument.

                            Reviewed-by: Todd Short <todd.short@me.com>
                            Reviewed-by: Matt Caswell <matt@openssl.org>
                            (Merged from https://github.com/openssl/openssl/pull/17986)

                            (cherry picked from commit 89dd85430770d39cbfb15eb586c921958ca7687f)

                        commit b7ce611887cfac633aacc052b2e71a7f195418b8
                        Author: Tomas Mraz <tomas@openssl.org>
                        Date:   Wed Jun 1 13:06:46 2022 +0200

                            ct_test.c: Update the epoch time

                            Reviewed-by: Matt Caswell <matt@openssl.org>
                            Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
                            (Merged from https://github.com/openssl/openssl/pull/18446)

                        commit 73db5d82489b3ec09ccc772dfcee14fef0e8e908
                        Author: Tomas Mraz <tomas@openssl.org>
                        Date:   Wed Jun 1 12:47:44 2022 +0200

                            Update expired SCT certificates

                            Reviewed-by: Matt Caswell <matt@openssl.org>
                            Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
                            (Merged from https://github.com/openssl/openssl/pull/18446)

                        commit 8754fa5f60ac4fdb5127f2eded9c7bbe0651c880
                        Author: Bernd Edlinger <bernd.edlinger@hotmail.de>
                        Date:   Sat May 21 07:50:46 2022 +0200

                            Fix a memory leak in crl_set_issuers

                            This can be reproduced with my error injection patch.

                            The test vector has been validated on the 1.1.1 branch
                            but the issue is of course identical in all branches.

                            $ ERROR_INJECT=1653520461 ../util/shlib_wrap.sh ./cms-test ./corpora/cms/3eff1d2f1232bd66d5635db2c3f9e7f23830dfd1
                            log file: cms-3eff1d2f1232bd66d5635db2c3f9e7f23830dfd1-32454-test.out
                            ERROR_INJECT=1653520461
                                #0 0x7fd5d8b8eeba in __sanitizer_print_stack_trace ../../../../gcc-trunk/libsanitizer/asan/asan_stack.cpp:87
                                #1 0x402fc4 in my_realloc fuzz/test-corpus.c:129
                                #2 0x7fd5d8893c49 in sk_reserve crypto/stack/stack.c:198
                                #3 0x7fd5d8893c49 in OPENSSL_sk_insert crypto/stack/stack.c:242
                                #4 0x7fd5d88d6d7f in sk_GENERAL_NAMES_push include/openssl/x509v3.h:168
                                #5 0x7fd5d88d6d7f in crl_set_issuers crypto/x509/x_crl.c:111
                                #6 0x7fd5d88d6d7f in crl_cb crypto/x509/x_crl.c:246
                                #7 0x7fd5d85dc032 in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:432
                                #8 0x7fd5d85dcaf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
                                #9 0x7fd5d85dd288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
                                #10 0x7fd5d85db2b5 in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:259
                                #11 0x7fd5d85dc813 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:611
                                #12 0x7fd5d85dd288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
                                #13 0x7fd5d85db9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                                #14 0x7fd5d85dca28 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:633
                                #15 0x7fd5d85dd288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
                                #16 0x7fd5d85db9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                                #17 0x7fd5d85dcaf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
                                #18 0x7fd5d85dd7d3 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:494
                                #19 0x7fd5d85db9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                                #20 0x7fd5d85ddd1f in ASN1_item_ex_d2i crypto/asn1/tasn_dec.c:124
                                #21 0x7fd5d85dde35 in ASN1_item_d2i crypto/asn1/tasn_dec.c:114
                                #22 0x7fd5d85a77e0 in ASN1_item_d2i_bio crypto/asn1/a_d2i_fp.c:69
                                #23 0x402845 in FuzzerTestOneInput fuzz/cms.c:43
                                #24 0x402bbb in testfile fuzz/test-corpus.c:182
                                #25 0x402626 in main fuzz/test-corpus.c:226
                                #26 0x7fd5d7c81f44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21f44)
                                #27 0x402706  (/home/ed/OPC/openssl/fuzz/cms-test+0x402706)

                            =================================================================
                            ==29625==ERROR: LeakSanitizer: detected memory leaks

                            Direct leak of 32 byte(s) in 1 object(s) allocated from:
                                #0 0x7fd5d8b8309f in __interceptor_malloc ../../../../gcc-trunk/libsanitizer/asan/asan_malloc_linux.cpp:69
                                #1 0x7fd5d87c2430 in CRYPTO_zalloc crypto/mem.c:230
                                #2 0x7fd5d889501f in OPENSSL_sk_new_reserve crypto/stack/stack.c:209
                                #3 0x7fd5d85dcbc3 in sk_ASN1_VALUE_new_null include/openssl/asn1t.h:928
                                #4 0x7fd5d85dcbc3 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:577
                                #5 0x7fd5d85dd288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
                                #6 0x7fd5d85db104 in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:178
                                #7 0x7fd5d85ddd1f in ASN1_item_ex_d2i crypto/asn1/tasn_dec.c:124
                                #8 0x7fd5d85dde35 in ASN1_item_d2i crypto/asn1/tasn_dec.c:114
                                #9 0x7fd5d88f86d9 in X509V3_EXT_d2i crypto/x509v3/v3_lib.c:142
                                #10 0x7fd5d88d6d3c in crl_set_issuers crypto/x509/x_crl.c:97
                                #11 0x7fd5d88d6d3c in crl_cb crypto/x509/x_crl.c:246
                                #12 0x7fd5d85dc032 in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:432
                                #13 0x7fd5d85dcaf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
                                #14 0x7fd5d85dd288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
                                #15 0x7fd5d85db2b5 in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:259
                                #16 0x7fd5d85dc813 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:611
                                #17 0x7fd5d85dd288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
                                #18 0x7fd5d85db9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                                #19 0x7fd5d85dca28 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:633
                                #20 0x7fd5d85dd288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
                                #21 0x7fd5d85db9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                                #22 0x7fd5d85dcaf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
                                #23 0x7fd5d85dd7d3 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:494
                                #24 0x7fd5d85db9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                                #25 0x7fd5d85ddd1f in ASN1_item_ex_d2i crypto/asn1/tasn_dec.c:124
                                #26 0x7fd5d85dde35 in ASN1_item_d2i crypto/asn1/tasn_dec.c:114
                                #27 0x7fd5d85a77e0 in ASN1_item_d2i_bio crypto/asn1/a_d2i_fp.c:69
                                #28 0x402845 in FuzzerTestOneInput fuzz/cms.c:43
                                #29 0x402bbb in testfile fuzz/test-corpus.c:182
                                #30 0x402626 in main fuzz/test-corpus.c:226
                                #31 0x7fd5d7c81f44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21f44)

                            SUMMARY: AddressSanitizer: 32 byte(s) leaked in 1 allocation(s).

                            Reviewed-by: Paul Dale <pauli@openssl.org>
                            Reviewed-by: Tomas Mraz <tomas@openssl.org>
                            (Merged from https://github.com/openssl/openssl/pull/18391)

                            (cherry picked from commit e9007e09792e3735d4973743634ff55d354fc7d8)

                        commit 4a28f8451fbc1848fd2d1b99203a7c75876123f6
                        Author: Bernd Edlinger <bernd.edlinger@hotmail.de>
                        Date:   Sun May 22 20:12:56 2022 +0200

                            Fix a crash in ssl_security_cert_chain

                            Prior to the crash there is an out of memory error
                            in X509_verify_cert which makes the chain NULL or
                            empty.  The error is ignored by ssl_add_cert_chain,
                            and ssl_security_cert_chain crashes due to the
                            unchecked null pointer.

                            This is reproducible with my error injection patch.

                            The test vector has been validated on the 1.1.1 branch
                            but the issue is of course identical in all branches.

                            $ ERROR_INJECT=1652848273 ../util/shlib_wrap.sh ./server-test ./corpora/server/47c8e933c4ec66fa3c309422283dfe0f31aafae8# ./corpora/server/47c8e933c4ec66fa3c309422283dfe0f31aafae8
                                #0 0x7f3a8f766eba in __sanitizer_print_stack_trace ../../../../gcc-trunk/libsanitizer/asan/asan_stack.cpp:87
                                #1 0x403ba4 in my_malloc fuzz/test-corpus.c:114
                                #2 0x7f3a8f39a430 in CRYPTO_zalloc crypto/mem.c:230
                                #3 0x7f3a8f46bd3b in sk_reserve crypto/stack/stack.c:180
                                #4 0x7f3a8f46bd3b in OPENSSL_sk_insert crypto/stack/stack.c:242
                                #5 0x7f3a8f4a4fd8 in sk_X509_push include/openssl/x509.h:99
                                #6 0x7f3a8f4a4fd8 in X509_verify_cert crypto/x509/x509_vfy.c:286
                                #7 0x7f3a8fed726e in ssl_add_cert_chain ssl/statem/statem_lib.c:959
                                #8 0x7f3a8fed726e in ssl3_output_cert_chain ssl/statem/statem_lib.c:1015
                                #9 0x7f3a8fee1c50 in tls_construct_server_certificate ssl/statem/statem_srvr.c:3812
                                #10 0x7f3a8feb8b0a in write_state_machine ssl/statem/statem.c:843
                                #11 0x7f3a8feb8b0a in state_machine ssl/statem/statem.c:443
                                #12 0x7f3a8fe84b3f in SSL_do_handshake ssl/ssl_lib.c:3718
                                #13 0x403202 in FuzzerTestOneInput fuzz/server.c:740
                                #14 0x40371b in testfile fuzz/test-corpus.c:182
                                #15 0x402856 in main fuzz/test-corpus.c:226
                                #16 0x7f3a8e859f44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21f44)
                                #17 0x402936  (/home/ed/OPC/openssl/fuzz/server-test+0x402936)

                            AddressSanitizer:DEADLYSIGNAL
                            =================================================================
                            ==8400==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000158 (pc 0x7f3a8f4d822f bp 0x7ffc39b76190 sp 0x7ffc39b760a0 T0)
                            ==8400==The signal is caused by a READ memory access.
                            ==8400==Hint: address points to the zero page.
                                #0 0x7f3a8f4d822f in x509v3_cache_extensions crypto/x509v3/v3_purp.c:386
                                #1 0x7f3a8f4d9d3a in X509_check_purpose crypto/x509v3/v3_purp.c:84
                                #2 0x7f3a8f4da02a in X509_get_extension_flags crypto/x509v3/v3_purp.c:921
                                #3 0x7f3a8feff7d2 in ssl_security_cert_sig ssl/t1_lib.c:2518
                                #4 0x7f3a8feff7d2 in ssl_security_cert ssl/t1_lib.c:2542
                                #5 0x7f3a8feffa03 in ssl_security_cert_chain ssl/t1_lib.c:2562
                                #6 0x7f3a8fed728d in ssl_add_cert_chain ssl/statem/statem_lib.c:963
                                #7 0x7f3a8fed728d in ssl3_output_cert_chain ssl/statem/statem_lib.c:1015
                                #8 0x7f3a8fee1c50 in tls_construct_server_certificate ssl/statem/statem_srvr.c:3812
                                #9 0x7f3a8feb8b0a in write_state_machine ssl/statem/statem.c:843
                                #10 0x7f3a8feb8b0a in state_machine ssl/statem/statem.c:443
                                #11 0x7f3a8fe84b3f in SSL_do_handshake ssl/ssl_lib.c:3718
                                #12 0x403202 in FuzzerTestOneInput fuzz/server.c:740
                                #13 0x40371b in testfile fuzz/test-corpus.c:182
                                #14 0x402856 in main fuzz/test-corpus.c:226
                                #15 0x7f3a8e859f44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21f44)
                                #16 0x402936  (/home/ed/OPC/openssl/fuzz/server-test+0x402936)

                            AddressSanitizer can not provide additional info.
                            SUMMARY: AddressSanitizer: SEGV crypto/x509v3/v3_purp.c:386 in x509v3_cache_extensions
                            ==8400==ABORTING

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

                            (cherry picked from commit dc0ef292f7df4ce0c49c64b47726a6768f9ac044)

                        commit 59b8eca400d9ea7b77dc98fe08a91bbfe35d025a
                        Author: Bernd Edlinger <bernd.edlinger@hotmail.de>
                        Date:   Sat May 21 15:41:46 2022 +0200

                            Fix a memory leak in X509_issuer_and_serial_hash

                            This is reproducible with my error injection patch:

                            $ ERROR_INJECT=1653267699 ../util/shlib_wrap.sh ./x509-test ./corpora/x509/5f4034ae85d6587dcad4da3e812e80f3d312894d
                            ERROR_INJECT=1653267699
                                #0 0x7fd485a6ad4f in __sanitizer_print_stack_trace ../../../../src/libsanitizer/asan/asan_stack.cc:36
                                #1 0x55c12d268724 in my_malloc fuzz/test-corpus.c:114
                                #2 0x7fd484f51a75 in CRYPTO_zalloc crypto/mem.c:230
                                #3 0x7fd484ed778d in EVP_DigestInit_ex crypto/evp/digest.c:139
                                #4 0x7fd4850a9849 in X509_issuer_and_serial_hash crypto/x509/x509_cmp.c:44
                                #5 0x55c12d268951 in FuzzerTestOneInput fuzz/x509.c:44
                                #6 0x55c12d268239 in testfile fuzz/test-corpus.c:182
                                #7 0x55c12d267c7f in main fuzz/test-corpus.c:226
                                #8 0x7fd483a42082 in __libc_start_main ../csu/libc-start.c:308
                                #9 0x55c12d267e5d in _start (/home/ed/OPCToolboxV5/Source/Core/OpenSSL/openssl/fuzz/x509-test+0x3e5d)

                            =================================================================
                            ==1058475==ERROR: LeakSanitizer: detected memory leaks

                            Direct leak of 268 byte(s) in 1 object(s) allocated from:
                                #0 0x7fd485a5dc3e in __interceptor_realloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:163
                                #1 0x7fd484d2eb9b in BUF_MEM_grow crypto/buffer/buffer.c:97
                                #2 0x7fd4850b2913 in X509_NAME_oneline crypto/x509/x509_obj.c:43
                                #3 0x7fd4850a982f in X509_issuer_and_serial_hash crypto/x509/x509_cmp.c:41
                                #4 0x55c12d268951 in FuzzerTestOneInput fuzz/x509.c:44
                                #5 0x55c12d268239 in testfile fuzz/test-corpus.c:182
                                #6 0x55c12d267c7f in main fuzz/test-corpus.c:226
                                #7 0x7fd483a42082 in __libc_start_main ../csu/libc-start.c:308

                            SUMMARY: AddressSanitizer: 268 byte(s) leaked in 1 allocation(s).

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

                        commit e4b84b7514e5cbcbfc80e31b4ce609c7584e14bb
                        Author: Bernd Edlinger <bernd.edlinger@hotmail.de>
                        Date:   Fri May 20 16:54:41 2022 +0200

                            Fix undefined behaviour in EC_GROUP_new_from_ecparameters

                            This happens for instance with
                            fuzz/corpora/asn1/65cf44e85614c62f10cf3b7a7184c26293a19e4a
                            and causes the OPENSSL_malloc below to choke on the
                            zero length allocation request.

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

                        commit 8e1ece20cdb4a584be5311370256c4e813c09826
                        Author: Bernd Edlinger <bernd.edlinger@hotmail.de>
                        Date:   Fri May 20 16:15:44 2022 +0200

                            Fix a memory leak in ec_key_simple_oct2priv

                            This is reproducible with my error injection patch:

                            $ ERROR_INJECT=1652710284 ../util/shlib_wrap.sh ./server-test ./corpora/server/4e48da8aecce6b9b58e8e4dbbf0523e6d2dd56dc
                            140587884632000:error:03078041:bignum routines:bn_expand_internal:malloc failure:crypto/bn/bn_lib.c:282:
                            140587884632000:error:10103003:elliptic curve routines:ec_key_simple_oct2priv:BN lib:crypto/ec/ec_key.c:662:
                            140587884632000:error:100DE08E:elliptic curve routines:old_ec_priv_decode:decode error:crypto/ec/ec_ameth.c:464:
                            140587884632000:error:0D0680A8:asn1 encoding routines:asn1_check_tlen:wrong tag:crypto/asn1/tasn_dec.c:1149:
                            140587884632000:error:0D07803A:asn1 encoding routines:asn1_item_embed_d2i:nested asn1 error:crypto/asn1/tasn_dec.c:309:Type=X509_ALGOR
                            140587884632000:error:0D08303A:asn1 encoding routines:asn1_template_noexp_d2i:nested asn1 error:crypto/asn1/tasn_dec.c:646:Field=pkeyalg, Type=PKCS8_PRIV_KEY_INFO
                            140587884632000:error:0907B00D:PEM routines:PEM_read_bio_PrivateKey:ASN1 lib:crypto/pem/pem_pkey.c:88:

                            =================================================================
                            ==19676==ERROR: LeakSanitizer: detected memory leaks

                            Direct leak of 24 byte(s) in 1 object(s) allocated from:
                                #0 0x7fdd2a6bb09f in __interceptor_malloc ../../../../gcc-trunk/libsanitizer/asan/asan_malloc_linux.cpp:69
                                #1 0x7fdd2a2fa430 in CRYPTO_zalloc crypto/mem.c:230
                                #2 0x7fdd2a15df11 in BN_new crypto/bn/bn_lib.c:246
                                #3 0x7fdd2a15df88 in BN_secure_new crypto/bn/bn_lib.c:257
                                #4 0x7fdd2a247390 in ec_key_simple_oct2priv crypto/ec/ec_key.c:655
                                #5 0x7fdd2a241fc5 in d2i_ECPrivateKey crypto/ec/ec_asn1.c:1030
                                #6 0x7fdd2a23dac5 in old_ec_priv_decode crypto/ec/ec_ameth.c:463
                                #7 0x7fdd2a109db7 in d2i_PrivateKey crypto/asn1/d2i_pr.c:46
                                #8 0x7fdd2a33ab16 in PEM_read_bio_PrivateKey crypto/pem/pem_pkey.c:84
                                #9 0x7fdd2a3330b6 in PEM_read_bio_ECPrivateKey crypto/pem/pem_all.c:151
                                #10 0x402dba in FuzzerTestOneInput fuzz/server.c:592
                                #11 0x40370b in testfile fuzz/test-corpus.c:182
                                #12 0x402846 in main fuzz/test-corpus.c:226
                                #13 0x7fdd297b9f44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21f44)

                            SUMMARY: AddressSanitizer: 24 byte(s) leaked in 1 allocation(s).

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

                        commit 8e60f41d064786f95440e4c56660ffe9777783d7
                        Author: Bernd Edlinger <bernd.edlinger@hotmail.de>
                        Date:   Fri May 20 08:02:47 2022 +0200

                            Fix a crash in asn1_item_embed_new

                            This happens usually if an template object is created
                            and there is an out of memory error before the ASN1_OP_NEW_POST
                            method is called, but asn1_item_embed_free calls now the
                            ASN1_OP_FREE_POST which may crash because the object is not
                            properly initialized.  Apparently that is only an issue with
                            the ASN1_OP_FREE_POST handling of crypot/x509/x_crl.c, which
                            ought to be tolerant to incomplete initialized objects.

                            The error can be reproduced with the reproducible error injection patch:

                            $ ERROR_INJECT=1652890550 ../util/shlib_wrap.sh ./asn1-test ./corpora/asn1/0ff17293911f54d1538b9896563a4048d67d9ee4
                                #0 0x7faae9dbeeba in __sanitizer_print_stack_trace ../../../../gcc-trunk/libsanitizer/asan/asan_stack.cpp:87
                                #1 0x408dc4 in my_malloc fuzz/test-corpus.c:114
                                #2 0x7faae99f2430 in CRYPTO_zalloc crypto/mem.c:230
                                #3 0x7faae97f09e5 in ASN1_STRING_type_new crypto/asn1/asn1_lib.c:341
                                #4 0x7faae98118f7 in asn1_primitive_new crypto/asn1/tasn_new.c:318
                                #5 0x7faae9812401 in asn1_item_embed_new crypto/asn1/tasn_new.c:78
                                #6 0x7faae9812401 in asn1_template_new crypto/asn1/tasn_new.c:240
                                #7 0x7faae9812315 in asn1_item_embed_new crypto/asn1/tasn_new.c:137
                                #8 0x7faae9812315 in asn1_template_new crypto/asn1/tasn_new.c:240
                                #9 0x7faae9812a54 in asn1_item_embed_new crypto/asn1/tasn_new.c:137
                                #10 0x7faae9812a54 in ASN1_item_ex_new crypto/asn1/tasn_new.c:39
                                #11 0x7faae980be51 in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:325
                                #12 0x7faae980c813 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:611
                                #13 0x7faae980d288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
                                #14 0x7faae980b9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                                #15 0x7faae980caf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
                                #16 0x7faae980d7d3 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:494
                                #17 0x7faae980b9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                                #18 0x7faae980dd1f in ASN1_item_ex_d2i crypto/asn1/tasn_dec.c:124
                                #19 0x7faae980de35 in ASN1_item_d2i crypto/asn1/tasn_dec.c:114
                                #20 0x40712c in FuzzerTestOneInput fuzz/asn1.c:301
                                #21 0x40893b in testfile fuzz/test-corpus.c:182
                                #22 0x406b86 in main fuzz/test-corpus.c:226
                                #23 0x7faae8eb1f44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21f44)

                            AddressSanitizer:DEADLYSIGNAL
                            =================================================================
                            ==1194==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000010 (pc 0x7faae9b0625f bp 0x7fffffe41a00 sp 0x7fffffe41920 T0)
                            ==1194==The signal is caused by a READ memory access.
                            ==1194==Hint: address points to the zero page.
                                #0 0x7faae9b0625f in crl_cb crypto/x509/x_crl.c:258
                                #1 0x7faae9811255 in asn1_item_embed_free crypto/asn1/tasn_fre.c:113
                                #2 0x7faae9812a65 in asn1_item_embed_new crypto/asn1/tasn_new.c:150
                                #3 0x7faae9812a65 in ASN1_item_ex_new crypto/asn1/tasn_new.c:39
                                #4 0x7faae980be51 in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:325
                                #5 0x7faae980c813 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:611
                                #6 0x7faae980d288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
                                #7 0x7faae980b9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                                #8 0x7faae980caf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
                                #9 0x7faae980d7d3 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:494
                                #10 0x7faae980b9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
                                #11 0x7faae980dd1f in ASN1_item_ex_d2i crypto/asn1/tasn_dec.c:124
                                #12 0x7faae980de35 in ASN1_item_d2i crypto/asn1/tasn_dec.c:114
                                #13 0x40712c in FuzzerTestOneInput fuzz/asn1.c:301
                                #14 0x40893b in testfile fuzz/test-corpus.c:182
                                #15 0x406b86 in main fuzz/test-corpus.c:226
                                #16 0x7faae8eb1f44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21f44)

                            AddressSanitizer can not provide additional info.
                            SUMMARY: AddressSanitizer: SEGV crypto/x509/x_crl.c:258 in crl_cb
                            ==1194==ABORTING

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

                            (cherry picked from commit 557825acd622f98fc21423aba092e374db84f483)

                        commit 17519e2595b5ed8211a7763ff6eb2d6cf47c13cb
                        Author: Bernd Edlinger <bernd.edlinger@hotmail.de>
                        Date:   Thu May 19 15:50:28 2022 +0200

                            Backport a missing bug-fix from master

                            This is a backport of the following commit from master:

                            commit 61b0fead5e6079ca826594df5b9ca00e65883cb0
                            Author: Matt Caswell <matt@openssl.org>
                            Date:   Thu Nov 19 13:58:21 2020 +0000

                                Don't Overflow when printing Thawte Strong Extranet Version

                                When printing human readable info on the Thawte Strong Extranet extension
                                the version number could overflow if the version number == LONG_MAX. This
                                is undefined behaviour.

                                Issue found by OSSFuzz.

                                Reviewed-by: Ben Kaduk <kaduk@mit.edu>
                                (Merged from https://github.com/openssl/openssl/pull/13452)

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

                        commit 03ba56f1525c93eb3dfe72f85cdc698b97918e59
                        Author: Bernd Edlinger <bernd.edlinger@hotmail.de>
                        Date:   Thu May 19 10:59:25 2022 +0200

                            Backport some fuzzing data files from master

                            This is a backport of the following commit from master:

                            commit 415e6ac80405e13b20b083315747e431274fbd33
                            Author: Tavis Ormandy <taviso@gmail.com>
                            Date:   Tue Sep 21 15:48:27 2021 -0700

                                increase x509 code coverage metrics

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

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

                        commit e04ba889594d84a8805f3d0caeadf0527470e508
                        Author: Daniel Fiala <daniel@openssl.org>
                        Date:   Tue May 10 08:46:37 2022 +0000

                            s_serve: Report an error if init-connection fails without an attempt to read.

                            Fixes: openssl#18047.

                            Reviewed-by: Paul Dale <pauli@openssl.org>
                            Reviewed-by: Tomas Mraz <tomas@openssl.org>
                            (Merged from https://github.com/openssl/openssl/pull/18283)

                        commit 6ef91d8153e04a2302bff11b29caf7e888b62fe8
                        Author: basavesh <basavesh.shivakumar@gmail.com>
                        Date:   Tue Apr 5 17:49:09 2022 +0200

                            Fix leakage when the cacheline is 32-bytes in CBC_MAC_ROTATE_IN_PLACE

                            rotated_mac is a 64-byte aligned buffer of size 64 and rotate_offset is secret.
                            Consider a weaker leakage model(CL) where only cacheline base address is leaked,
                            i.e address/32 for 32-byte cacheline(CL32).

                            Previous code used to perform two loads
                                1. rotated_mac[rotate_offset ^ 32] and
                                2. rotated_mac[rotate_offset++]
                            which would leak 2q + 1, 2q for 0 <= rotate_offset < 32
                            and 2q, 2q + 1 for 32 <= rotate_offset < 64

                            The proposed fix performs load operations which will always leak 2q, 2q + 1 and
                            selects the appropriate value in constant-time.

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

                        commit c7d6c08290b67cbeef2b4f636f04788ea405520a
                        Author: Tomas Mraz <tomas@openssl.org>
                        Date:   Fri Apr 29 17:02:19 2022 +0200

                            Add test for empty supported-groups extension

                            Reviewed-by: Paul Dale <pauli@openssl.org>
                            Reviewed-by: Matt Caswell <matt@openssl.org>
                            (Merged from https://github.com/openssl/openssl/pull/18213)

                        commit bd164884f258d99ca876f6cdcdf9bd0dcceee6ad
                        Author: Tomas Mraz <tomas@openssl.org>
                        Date:   Fri Apr 29 16:36:36 2022 +0200

                            Do not send an empty supported groups extension

                            This allows handshake to proceed if the maximum TLS version enabled is <1.3

                            Fixes #13583

                            Reviewed-by: Paul Dale <pauli@openssl.org>
                            Reviewed-by: Matt Caswell <matt@openssl.org>
                            (Merged from https://github.com/openssl/openssl/pull/18213)

                        commit ac2d4cb656b3a796db3dc6f8873e91e67907372d
                        Author: Allan Jude <allan@klarasystems.com>
                        Date:   Fri Nov 19 19:06:52 2021 +0000

                            1_1_1-stable: Detect arm64-*-*bsd and enable assembly optimizations

                            Reviewed-by: Paul Dale <pauli@openssl.org>
                            Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
                            Reviewed-by: Tomas Mraz <tomas@openssl.org>
                            (Merged from https://github.com/openssl/openssl/pull/17085)

                        commit ec1b4bf26c1b2440546f323873c578374f60b2de
                        Author: Hugo Landau <hlandau@openssl.org>
                        Date:   Wed Apr 27 10:11:08 2022 +0100

                            (1.1) Add SSL_(CTX_)?get0_(verify|chain)_cert_store functions

                            Backport of #18038 to 1.1.

                            Fixes #18035.

                            Reviewed-by: Tomas Mraz <tomas@openssl.org>
                            Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
                            (Merged from https://github.com/openssl/openssl/pull/18190)

                        commit 988c7b2d9361dd0ade5ef7ef068fb4ed770ce2a2
                        Author: Matt Caswell <matt@openssl.org>
                        Date:   Tue May 3 14:41:23 2022 +0100

                            Prepare for 1.1.1p-dev

                            Reviewed-by: Tomas Mraz <tomas@openssl.org>
                            Release: yes

                    commit 5ea6414f0bf861e8fece53b5bf35c849bad64774
                    Author: Randall S. Becker <rsbecker@nexbridge.com>
                    Date:   Wed Jun 22 06:26:40 2022 -0600

                        Squashed commit of the following:

                        commit 8aaca20cf9996257d1ce2e6f4d3059b3698dde3d
                        Author: Matt Caswell <matt@openssl.org>
                        Date:   Tue Jun 21 14:39:39 2022 +0100

                            Prepare for 1.1.1p release

                            Reviewed-by: Richard Levitte <levitte@openssl.org>
                            Release: yes

                        commit a3fc812c0c78e2f5db8b9d45bddaff62dfc958ae
                        Author: Matt Caswell <matt@openssl.org>
                        Date:   Tue Jun 21 14:07:32 2022 +0100

                            Update copyright year

                            Reviewed-by: Richard Levitte <levitte@openssl.org>
                            Release: yes

                        commit 51e06520734063d6f52b2e596e1089d36d3781e7
                        Author: Matt Caswell <matt@openssl.org>
                        Date:   Mon Jun 20 14:14:20 2022 +0100

                  …
tmshort pushed a commit to tmshort/openssl that referenced this pull request Sep 11, 2023
bernd-edlinger added a commit to bernd-edlinger/openssl that referenced this pull request Dec 22, 2023
Sometimes the error handling returns an ASN1_STRING
object in *out although that was not passed in by the
caller, and sometimes the error handling deletes the
ASN1_STRING but forgets to clear the *out parameter.
Therfore the caller has no chance to know, if the leaked
object in *out shall be deleted or not.
This may cause a use-after-free error e.g. in asn1_str2type:

==63312==ERROR: AddressSanitizer: heap-use-after-free on address 0x603000073280 at pc 0x7f2652e93b08 bp 0x7ffe0e1951c0 sp 0x7ffe0e1951b0
READ of size 8 at 0x603000073280 thread T0
    #0 0x7f2652e93b07 in asn1_string_embed_free crypto/asn1/asn1_lib.c:354
    openssl#1 0x7f2652eb521a in asn1_primitive_free crypto/asn1/tasn_fre.c:204
    openssl#2 0x7f2652eb50a9 in asn1_primitive_free crypto/asn1/tasn_fre.c:199
    openssl#3 0x7f2652eb5b67 in ASN1_item_free crypto/asn1/tasn_fre.c:20
    openssl#4 0x7f2652e8e13b in asn1_str2type crypto/asn1/asn1_gen.c:740
    openssl#5 0x7f2652e8e13b in generate_v3 crypto/asn1/asn1_gen.c:137
    openssl#6 0x7f2652e9166c in ASN1_generate_v3 crypto/asn1/asn1_gen.c:92
    openssl#7 0x7f2653307b9b in do_othername crypto/x509v3/v3_alt.c:577
    openssl#8 0x7f2653307b9b in a2i_GENERAL_NAME crypto/x509v3/v3_alt.c:492
    openssl#9 0x7f26533087c2 in v2i_subject_alt crypto/x509v3/v3_alt.c:327
    openssl#10 0x7f26533107fc in do_ext_nconf crypto/x509v3/v3_conf.c:100
    openssl#11 0x7f2653310f33 in X509V3_EXT_nconf crypto/x509v3/v3_conf.c:45
    openssl#12 0x7f2653311426 in X509V3_EXT_add_nconf_sk crypto/x509v3/v3_conf.c:312
    openssl#13 0x7f265331170c in X509V3_EXT_REQ_add_nconf crypto/x509v3/v3_conf.c:360
    openssl#14 0x564ed19d5f25 in req_main apps/req.c:806
    openssl#15 0x564ed19b8de0 in do_cmd apps/openssl.c:564
    openssl#16 0x564ed1985165 in main apps/openssl.c:183
    openssl#17 0x7f2651c4a082 in __libc_start_main ../csu/libc-start.c:308
    openssl#18 0x564ed1985acd in _start (/home/ed/OPCToolboxV5/Source/Core/OpenSSL/openssl/apps/openssl+0x139acd)

0x603000073280 is located 16 bytes inside of 24-byte region [0x603000073270,0x603000073288)
freed by thread T0 here:
    #0 0x7f265413440f in __interceptor_free ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:122
    openssl#1 0x7f265315a429 in CRYPTO_free crypto/mem.c:311
    openssl#2 0x7f265315a429 in CRYPTO_free crypto/mem.c:300
    openssl#3 0x7f2652e757b9 in ASN1_mbstring_ncopy crypto/asn1/a_mbstr.c:191
    openssl#4 0x7f2652e75ec5 in ASN1_mbstring_copy crypto/asn1/a_mbstr.c:38
    openssl#5 0x7f2652e8e227 in asn1_str2type crypto/asn1/asn1_gen.c:681
    openssl#6 0x7f2652e8e227 in generate_v3 crypto/asn1/asn1_gen.c:137
    openssl#7 0x7f2652e9166c in ASN1_generate_v3 crypto/asn1/asn1_gen.c:92
    openssl#8 0x7f2653307b9b in do_othername crypto/x509v3/v3_alt.c:577
    openssl#9 0x7f2653307b9b in a2i_GENERAL_NAME crypto/x509v3/v3_alt.c:492
    openssl#10 0x7f26533087c2 in v2i_subject_alt crypto/x509v3/v3_alt.c:327
    openssl#11 0x7f26533107fc in do_ext_nconf crypto/x509v3/v3_conf.c:100
    openssl#12 0x7f2653310f33 in X509V3_EXT_nconf crypto/x509v3/v3_conf.c:45
    openssl#13 0x7f2653311426 in X509V3_EXT_add_nconf_sk crypto/x509v3/v3_conf.c:312
    openssl#14 0x7f265331170c in X509V3_EXT_REQ_add_nconf crypto/x509v3/v3_conf.c:360
    openssl#15 0x564ed19d5f25 in req_main apps/req.c:806
    openssl#16 0x564ed19b8de0 in do_cmd apps/openssl.c:564
    openssl#17 0x564ed1985165 in main apps/openssl.c:183
    openssl#18 0x7f2651c4a082 in __libc_start_main ../csu/libc-start.c:308

previously allocated by thread T0 here:
    #0 0x7f2654134808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    openssl#1 0x7f265315a4fd in CRYPTO_malloc crypto/mem.c:221
    openssl#2 0x7f265315a4fd in CRYPTO_malloc crypto/mem.c:198
    openssl#3 0x7f265315a945 in CRYPTO_zalloc crypto/mem.c:236
    openssl#4 0x7f2652e939a4 in ASN1_STRING_type_new crypto/asn1/asn1_lib.c:341
    openssl#5 0x7f2652e74e51 in ASN1_mbstring_ncopy crypto/asn1/a_mbstr.c:150
    openssl#6 0x7f2652e75ec5 in ASN1_mbstring_copy crypto/asn1/a_mbstr.c:38
    openssl#7 0x7f2652e8e227 in asn1_str2type crypto/asn1/asn1_gen.c:681
    openssl#8 0x7f2652e8e227 in generate_v3 crypto/asn1/asn1_gen.c:137
    openssl#9 0x7f2652e9166c in ASN1_generate_v3 crypto/asn1/asn1_gen.c:92
    openssl#10 0x7f2653307b9b in do_othername crypto/x509v3/v3_alt.c:577
    openssl#11 0x7f2653307b9b in a2i_GENERAL_NAME crypto/x509v3/v3_alt.c:492
    openssl#12 0x7f26533087c2 in v2i_subject_alt crypto/x509v3/v3_alt.c:327
    openssl#13 0x7f26533107fc in do_ext_nconf crypto/x509v3/v3_conf.c:100
    openssl#14 0x7f2653310f33 in X509V3_EXT_nconf crypto/x509v3/v3_conf.c:45
    openssl#15 0x7f2653311426 in X509V3_EXT_add_nconf_sk crypto/x509v3/v3_conf.c:312
    openssl#16 0x7f265331170c in X509V3_EXT_REQ_add_nconf crypto/x509v3/v3_conf.c:360
    openssl#17 0x564ed19d5f25 in req_main apps/req.c:806
    openssl#18 0x564ed19b8de0 in do_cmd apps/openssl.c:564
    openssl#19 0x564ed1985165 in main apps/openssl.c:183
    openssl#20 0x7f2651c4a082 in __libc_start_main ../csu/libc-start.c:308
bernd-edlinger added a commit to bernd-edlinger/openssl that referenced this pull request Dec 22, 2023
Sometimes the error handling returns an ASN1_STRING
object in *out although that was not passed in by the
caller, and sometimes the error handling deletes the
ASN1_STRING but forgets to clear the *out parameter.
Therefore the caller has no chance to know, if the leaked
object in *out shall be deleted or not.
This may cause a use-after-free error e.g. in asn1_str2type:

==63312==ERROR: AddressSanitizer: heap-use-after-free on address 0x603000073280 at pc 0x7f2652e93b08 bp 0x7ffe0e1951c0 sp 0x7ffe0e1951b0
READ of size 8 at 0x603000073280 thread T0
    #0 0x7f2652e93b07 in asn1_string_embed_free crypto/asn1/asn1_lib.c:354
    openssl#1 0x7f2652eb521a in asn1_primitive_free crypto/asn1/tasn_fre.c:204
    openssl#2 0x7f2652eb50a9 in asn1_primitive_free crypto/asn1/tasn_fre.c:199
    openssl#3 0x7f2652eb5b67 in ASN1_item_free crypto/asn1/tasn_fre.c:20
    openssl#4 0x7f2652e8e13b in asn1_str2type crypto/asn1/asn1_gen.c:740
    openssl#5 0x7f2652e8e13b in generate_v3 crypto/asn1/asn1_gen.c:137
    openssl#6 0x7f2652e9166c in ASN1_generate_v3 crypto/asn1/asn1_gen.c:92
    openssl#7 0x7f2653307b9b in do_othername crypto/x509v3/v3_alt.c:577
    openssl#8 0x7f2653307b9b in a2i_GENERAL_NAME crypto/x509v3/v3_alt.c:492
    openssl#9 0x7f26533087c2 in v2i_subject_alt crypto/x509v3/v3_alt.c:327
    openssl#10 0x7f26533107fc in do_ext_nconf crypto/x509v3/v3_conf.c:100
    openssl#11 0x7f2653310f33 in X509V3_EXT_nconf crypto/x509v3/v3_conf.c:45
    openssl#12 0x7f2653311426 in X509V3_EXT_add_nconf_sk crypto/x509v3/v3_conf.c:312
    openssl#13 0x7f265331170c in X509V3_EXT_REQ_add_nconf crypto/x509v3/v3_conf.c:360
    openssl#14 0x564ed19d5f25 in req_main apps/req.c:806
    openssl#15 0x564ed19b8de0 in do_cmd apps/openssl.c:564
    openssl#16 0x564ed1985165 in main apps/openssl.c:183
    openssl#17 0x7f2651c4a082 in __libc_start_main ../csu/libc-start.c:308
    openssl#18 0x564ed1985acd in _start (/home/ed/OPCToolboxV5/Source/Core/OpenSSL/openssl/apps/openssl+0x139acd)

0x603000073280 is located 16 bytes inside of 24-byte region [0x603000073270,0x603000073288)
freed by thread T0 here:
    #0 0x7f265413440f in __interceptor_free ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:122
    openssl#1 0x7f265315a429 in CRYPTO_free crypto/mem.c:311
    openssl#2 0x7f265315a429 in CRYPTO_free crypto/mem.c:300
    openssl#3 0x7f2652e757b9 in ASN1_mbstring_ncopy crypto/asn1/a_mbstr.c:191
    openssl#4 0x7f2652e75ec5 in ASN1_mbstring_copy crypto/asn1/a_mbstr.c:38
    openssl#5 0x7f2652e8e227 in asn1_str2type crypto/asn1/asn1_gen.c:681
    openssl#6 0x7f2652e8e227 in generate_v3 crypto/asn1/asn1_gen.c:137
    openssl#7 0x7f2652e9166c in ASN1_generate_v3 crypto/asn1/asn1_gen.c:92
    openssl#8 0x7f2653307b9b in do_othername crypto/x509v3/v3_alt.c:577
    openssl#9 0x7f2653307b9b in a2i_GENERAL_NAME crypto/x509v3/v3_alt.c:492
    openssl#10 0x7f26533087c2 in v2i_subject_alt crypto/x509v3/v3_alt.c:327
    openssl#11 0x7f26533107fc in do_ext_nconf crypto/x509v3/v3_conf.c:100
    openssl#12 0x7f2653310f33 in X509V3_EXT_nconf crypto/x509v3/v3_conf.c:45
    openssl#13 0x7f2653311426 in X509V3_EXT_add_nconf_sk crypto/x509v3/v3_conf.c:312
    openssl#14 0x7f265331170c in X509V3_EXT_REQ_add_nconf crypto/x509v3/v3_conf.c:360
    openssl#15 0x564ed19d5f25 in req_main apps/req.c:806
    openssl#16 0x564ed19b8de0 in do_cmd apps/openssl.c:564
    openssl#17 0x564ed1985165 in main apps/openssl.c:183
    openssl#18 0x7f2651c4a082 in __libc_start_main ../csu/libc-start.c:308

previously allocated by thread T0 here:
    #0 0x7f2654134808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    openssl#1 0x7f265315a4fd in CRYPTO_malloc crypto/mem.c:221
    openssl#2 0x7f265315a4fd in CRYPTO_malloc crypto/mem.c:198
    openssl#3 0x7f265315a945 in CRYPTO_zalloc crypto/mem.c:236
    openssl#4 0x7f2652e939a4 in ASN1_STRING_type_new crypto/asn1/asn1_lib.c:341
    openssl#5 0x7f2652e74e51 in ASN1_mbstring_ncopy crypto/asn1/a_mbstr.c:150
    openssl#6 0x7f2652e75ec5 in ASN1_mbstring_copy crypto/asn1/a_mbstr.c:38
    openssl#7 0x7f2652e8e227 in asn1_str2type crypto/asn1/asn1_gen.c:681
    openssl#8 0x7f2652e8e227 in generate_v3 crypto/asn1/asn1_gen.c:137
    openssl#9 0x7f2652e9166c in ASN1_generate_v3 crypto/asn1/asn1_gen.c:92
    openssl#10 0x7f2653307b9b in do_othername crypto/x509v3/v3_alt.c:577
    openssl#11 0x7f2653307b9b in a2i_GENERAL_NAME crypto/x509v3/v3_alt.c:492
    openssl#12 0x7f26533087c2 in v2i_subject_alt crypto/x509v3/v3_alt.c:327
    openssl#13 0x7f26533107fc in do_ext_nconf crypto/x509v3/v3_conf.c:100
    openssl#14 0x7f2653310f33 in X509V3_EXT_nconf crypto/x509v3/v3_conf.c:45
    openssl#15 0x7f2653311426 in X509V3_EXT_add_nconf_sk crypto/x509v3/v3_conf.c:312
    openssl#16 0x7f265331170c in X509V3_EXT_REQ_add_nconf crypto/x509v3/v3_conf.c:360
    openssl#17 0x564ed19d5f25 in req_main apps/req.c:806
    openssl#18 0x564ed19b8de0 in do_cmd apps/openssl.c:564
    openssl#19 0x564ed1985165 in main apps/openssl.c:183
    openssl#20 0x7f2651c4a082 in __libc_start_main ../csu/libc-start.c:308
openssl-machine pushed a commit that referenced this pull request Dec 29, 2023
Sometimes the error handling returns an ASN1_STRING
object in *out although that was not passed in by the
caller, and sometimes the error handling deletes the
ASN1_STRING but forgets to clear the *out parameter.
Therefore the caller has no chance to know, if the leaked
object in *out shall be deleted or not.
This may cause a use-after-free error e.g. in asn1_str2type:

==63312==ERROR: AddressSanitizer: heap-use-after-free on address 0x603000073280 at pc 0x7f2652e93b08 bp 0x7ffe0e1951c0 sp 0x7ffe0e1951b0
READ of size 8 at 0x603000073280 thread T0
    #0 0x7f2652e93b07 in asn1_string_embed_free crypto/asn1/asn1_lib.c:354
    #1 0x7f2652eb521a in asn1_primitive_free crypto/asn1/tasn_fre.c:204
    #2 0x7f2652eb50a9 in asn1_primitive_free crypto/asn1/tasn_fre.c:199
    #3 0x7f2652eb5b67 in ASN1_item_free crypto/asn1/tasn_fre.c:20
    #4 0x7f2652e8e13b in asn1_str2type crypto/asn1/asn1_gen.c:740
    #5 0x7f2652e8e13b in generate_v3 crypto/asn1/asn1_gen.c:137
    #6 0x7f2652e9166c in ASN1_generate_v3 crypto/asn1/asn1_gen.c:92
    #7 0x7f2653307b9b in do_othername crypto/x509v3/v3_alt.c:577
    #8 0x7f2653307b9b in a2i_GENERAL_NAME crypto/x509v3/v3_alt.c:492
    #9 0x7f26533087c2 in v2i_subject_alt crypto/x509v3/v3_alt.c:327
    #10 0x7f26533107fc in do_ext_nconf crypto/x509v3/v3_conf.c:100
    #11 0x7f2653310f33 in X509V3_EXT_nconf crypto/x509v3/v3_conf.c:45
    #12 0x7f2653311426 in X509V3_EXT_add_nconf_sk crypto/x509v3/v3_conf.c:312
    #13 0x7f265331170c in X509V3_EXT_REQ_add_nconf crypto/x509v3/v3_conf.c:360
    #14 0x564ed19d5f25 in req_main apps/req.c:806
    #15 0x564ed19b8de0 in do_cmd apps/openssl.c:564
    #16 0x564ed1985165 in main apps/openssl.c:183
    #17 0x7f2651c4a082 in __libc_start_main ../csu/libc-start.c:308
    #18 0x564ed1985acd in _start (/home/ed/OPCToolboxV5/Source/Core/OpenSSL/openssl/apps/openssl+0x139acd)

0x603000073280 is located 16 bytes inside of 24-byte region [0x603000073270,0x603000073288)
freed by thread T0 here:
    #0 0x7f265413440f in __interceptor_free ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:122
    #1 0x7f265315a429 in CRYPTO_free crypto/mem.c:311
    #2 0x7f265315a429 in CRYPTO_free crypto/mem.c:300
    #3 0x7f2652e757b9 in ASN1_mbstring_ncopy crypto/asn1/a_mbstr.c:191
    #4 0x7f2652e75ec5 in ASN1_mbstring_copy crypto/asn1/a_mbstr.c:38
    #5 0x7f2652e8e227 in asn1_str2type crypto/asn1/asn1_gen.c:681
    #6 0x7f2652e8e227 in generate_v3 crypto/asn1/asn1_gen.c:137
    #7 0x7f2652e9166c in ASN1_generate_v3 crypto/asn1/asn1_gen.c:92
    #8 0x7f2653307b9b in do_othername crypto/x509v3/v3_alt.c:577
    #9 0x7f2653307b9b in a2i_GENERAL_NAME crypto/x509v3/v3_alt.c:492
    #10 0x7f26533087c2 in v2i_subject_alt crypto/x509v3/v3_alt.c:327
    #11 0x7f26533107fc in do_ext_nconf crypto/x509v3/v3_conf.c:100
    #12 0x7f2653310f33 in X509V3_EXT_nconf crypto/x509v3/v3_conf.c:45
    #13 0x7f2653311426 in X509V3_EXT_add_nconf_sk crypto/x509v3/v3_conf.c:312
    #14 0x7f265331170c in X509V3_EXT_REQ_add_nconf crypto/x509v3/v3_conf.c:360
    #15 0x564ed19d5f25 in req_main apps/req.c:806
    #16 0x564ed19b8de0 in do_cmd apps/openssl.c:564
    #17 0x564ed1985165 in main apps/openssl.c:183
    #18 0x7f2651c4a082 in __libc_start_main ../csu/libc-start.c:308

previously allocated by thread T0 here:
    #0 0x7f2654134808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x7f265315a4fd in CRYPTO_malloc crypto/mem.c:221
    #2 0x7f265315a4fd in CRYPTO_malloc crypto/mem.c:198
    #3 0x7f265315a945 in CRYPTO_zalloc crypto/mem.c:236
    #4 0x7f2652e939a4 in ASN1_STRING_type_new crypto/asn1/asn1_lib.c:341
    #5 0x7f2652e74e51 in ASN1_mbstring_ncopy crypto/asn1/a_mbstr.c:150
    #6 0x7f2652e75ec5 in ASN1_mbstring_copy crypto/asn1/a_mbstr.c:38
    #7 0x7f2652e8e227 in asn1_str2type crypto/asn1/asn1_gen.c:681
    #8 0x7f2652e8e227 in generate_v3 crypto/asn1/asn1_gen.c:137
    #9 0x7f2652e9166c in ASN1_generate_v3 crypto/asn1/asn1_gen.c:92
    #10 0x7f2653307b9b in do_othername crypto/x509v3/v3_alt.c:577
    #11 0x7f2653307b9b in a2i_GENERAL_NAME crypto/x509v3/v3_alt.c:492
    #12 0x7f26533087c2 in v2i_subject_alt crypto/x509v3/v3_alt.c:327
    #13 0x7f26533107fc in do_ext_nconf crypto/x509v3/v3_conf.c:100
    #14 0x7f2653310f33 in X509V3_EXT_nconf crypto/x509v3/v3_conf.c:45
    #15 0x7f2653311426 in X509V3_EXT_add_nconf_sk crypto/x509v3/v3_conf.c:312
    #16 0x7f265331170c in X509V3_EXT_REQ_add_nconf crypto/x509v3/v3_conf.c:360
    #17 0x564ed19d5f25 in req_main apps/req.c:806
    #18 0x564ed19b8de0 in do_cmd apps/openssl.c:564
    #19 0x564ed1985165 in main apps/openssl.c:183
    #20 0x7f2651c4a082 in __libc_start_main ../csu/libc-start.c:308

Reviewed-by: Paul Yang <kaishen.yy@antfin.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #23138)

(cherry picked from commit 73ebaac)
openssl-machine pushed a commit that referenced this pull request Dec 29, 2023
Sometimes the error handling returns an ASN1_STRING
object in *out although that was not passed in by the
caller, and sometimes the error handling deletes the
ASN1_STRING but forgets to clear the *out parameter.
Therefore the caller has no chance to know, if the leaked
object in *out shall be deleted or not.
This may cause a use-after-free error e.g. in asn1_str2type:

==63312==ERROR: AddressSanitizer: heap-use-after-free on address 0x603000073280 at pc 0x7f2652e93b08 bp 0x7ffe0e1951c0 sp 0x7ffe0e1951b0
READ of size 8 at 0x603000073280 thread T0
    #0 0x7f2652e93b07 in asn1_string_embed_free crypto/asn1/asn1_lib.c:354
    #1 0x7f2652eb521a in asn1_primitive_free crypto/asn1/tasn_fre.c:204
    #2 0x7f2652eb50a9 in asn1_primitive_free crypto/asn1/tasn_fre.c:199
    #3 0x7f2652eb5b67 in ASN1_item_free crypto/asn1/tasn_fre.c:20
    #4 0x7f2652e8e13b in asn1_str2type crypto/asn1/asn1_gen.c:740
    #5 0x7f2652e8e13b in generate_v3 crypto/asn1/asn1_gen.c:137
    #6 0x7f2652e9166c in ASN1_generate_v3 crypto/asn1/asn1_gen.c:92
    #7 0x7f2653307b9b in do_othername crypto/x509v3/v3_alt.c:577
    #8 0x7f2653307b9b in a2i_GENERAL_NAME crypto/x509v3/v3_alt.c:492
    #9 0x7f26533087c2 in v2i_subject_alt crypto/x509v3/v3_alt.c:327
    #10 0x7f26533107fc in do_ext_nconf crypto/x509v3/v3_conf.c:100
    #11 0x7f2653310f33 in X509V3_EXT_nconf crypto/x509v3/v3_conf.c:45
    #12 0x7f2653311426 in X509V3_EXT_add_nconf_sk crypto/x509v3/v3_conf.c:312
    #13 0x7f265331170c in X509V3_EXT_REQ_add_nconf crypto/x509v3/v3_conf.c:360
    #14 0x564ed19d5f25 in req_main apps/req.c:806
    #15 0x564ed19b8de0 in do_cmd apps/openssl.c:564
    #16 0x564ed1985165 in main apps/openssl.c:183
    #17 0x7f2651c4a082 in __libc_start_main ../csu/libc-start.c:308
    #18 0x564ed1985acd in _start (/home/ed/OPCToolboxV5/Source/Core/OpenSSL/openssl/apps/openssl+0x139acd)

0x603000073280 is located 16 bytes inside of 24-byte region [0x603000073270,0x603000073288)
freed by thread T0 here:
    #0 0x7f265413440f in __interceptor_free ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:122
    #1 0x7f265315a429 in CRYPTO_free crypto/mem.c:311
    #2 0x7f265315a429 in CRYPTO_free crypto/mem.c:300
    #3 0x7f2652e757b9 in ASN1_mbstring_ncopy crypto/asn1/a_mbstr.c:191
    #4 0x7f2652e75ec5 in ASN1_mbstring_copy crypto/asn1/a_mbstr.c:38
    #5 0x7f2652e8e227 in asn1_str2type crypto/asn1/asn1_gen.c:681
    #6 0x7f2652e8e227 in generate_v3 crypto/asn1/asn1_gen.c:137
    #7 0x7f2652e9166c in ASN1_generate_v3 crypto/asn1/asn1_gen.c:92
    #8 0x7f2653307b9b in do_othername crypto/x509v3/v3_alt.c:577
    #9 0x7f2653307b9b in a2i_GENERAL_NAME crypto/x509v3/v3_alt.c:492
    #10 0x7f26533087c2 in v2i_subject_alt crypto/x509v3/v3_alt.c:327
    #11 0x7f26533107fc in do_ext_nconf crypto/x509v3/v3_conf.c:100
    #12 0x7f2653310f33 in X509V3_EXT_nconf crypto/x509v3/v3_conf.c:45
    #13 0x7f2653311426 in X509V3_EXT_add_nconf_sk crypto/x509v3/v3_conf.c:312
    #14 0x7f265331170c in X509V3_EXT_REQ_add_nconf crypto/x509v3/v3_conf.c:360
    #15 0x564ed19d5f25 in req_main apps/req.c:806
    #16 0x564ed19b8de0 in do_cmd apps/openssl.c:564
    #17 0x564ed1985165 in main apps/openssl.c:183
    #18 0x7f2651c4a082 in __libc_start_main ../csu/libc-start.c:308

previously allocated by thread T0 here:
    #0 0x7f2654134808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x7f265315a4fd in CRYPTO_malloc crypto/mem.c:221
    #2 0x7f265315a4fd in CRYPTO_malloc crypto/mem.c:198
    #3 0x7f265315a945 in CRYPTO_zalloc crypto/mem.c:236
    #4 0x7f2652e939a4 in ASN1_STRING_type_new crypto/asn1/asn1_lib.c:341
    #5 0x7f2652e74e51 in ASN1_mbstring_ncopy crypto/asn1/a_mbstr.c:150
    #6 0x7f2652e75ec5 in ASN1_mbstring_copy crypto/asn1/a_mbstr.c:38
    #7 0x7f2652e8e227 in asn1_str2type crypto/asn1/asn1_gen.c:681
    #8 0x7f2652e8e227 in generate_v3 crypto/asn1/asn1_gen.c:137
    #9 0x7f2652e9166c in ASN1_generate_v3 crypto/asn1/asn1_gen.c:92
    #10 0x7f2653307b9b in do_othername crypto/x509v3/v3_alt.c:577
    #11 0x7f2653307b9b in a2i_GENERAL_NAME crypto/x509v3/v3_alt.c:492
    #12 0x7f26533087c2 in v2i_subject_alt crypto/x509v3/v3_alt.c:327
    #13 0x7f26533107fc in do_ext_nconf crypto/x509v3/v3_conf.c:100
    #14 0x7f2653310f33 in X509V3_EXT_nconf crypto/x509v3/v3_conf.c:45
    #15 0x7f2653311426 in X509V3_EXT_add_nconf_sk crypto/x509v3/v3_conf.c:312
    #16 0x7f265331170c in X509V3_EXT_REQ_add_nconf crypto/x509v3/v3_conf.c:360
    #17 0x564ed19d5f25 in req_main apps/req.c:806
    #18 0x564ed19b8de0 in do_cmd apps/openssl.c:564
    #19 0x564ed1985165 in main apps/openssl.c:183
    #20 0x7f2651c4a082 in __libc_start_main ../csu/libc-start.c:308

Reviewed-by: Paul Yang <kaishen.yy@antfin.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #23138)
bernd-edlinger added a commit to bernd-edlinger/openssl that referenced this pull request Dec 29, 2023
Sometimes the error handling returns an ASN1_STRING
object in *out although that was not passed in by the
caller, and sometimes the error handling deletes the
ASN1_STRING but forgets to clear the *out parameter.
Therefore the caller has no chance to know, if the leaked
object in *out shall be deleted or not.
This may cause a use-after-free error e.g. in asn1_str2type:

==63312==ERROR: AddressSanitizer: heap-use-after-free on address 0x603000073280 at pc 0x7f2652e93b08 bp 0x7ffe0e1951c0 sp 0x7ffe0e1951b0
READ of size 8 at 0x603000073280 thread T0
    #0 0x7f2652e93b07 in asn1_string_embed_free crypto/asn1/asn1_lib.c:354
    openssl#1 0x7f2652eb521a in asn1_primitive_free crypto/asn1/tasn_fre.c:204
    openssl#2 0x7f2652eb50a9 in asn1_primitive_free crypto/asn1/tasn_fre.c:199
    openssl#3 0x7f2652eb5b67 in ASN1_item_free crypto/asn1/tasn_fre.c:20
    openssl#4 0x7f2652e8e13b in asn1_str2type crypto/asn1/asn1_gen.c:740
    openssl#5 0x7f2652e8e13b in generate_v3 crypto/asn1/asn1_gen.c:137
    openssl#6 0x7f2652e9166c in ASN1_generate_v3 crypto/asn1/asn1_gen.c:92
    openssl#7 0x7f2653307b9b in do_othername crypto/x509v3/v3_alt.c:577
    openssl#8 0x7f2653307b9b in a2i_GENERAL_NAME crypto/x509v3/v3_alt.c:492
    openssl#9 0x7f26533087c2 in v2i_subject_alt crypto/x509v3/v3_alt.c:327
    openssl#10 0x7f26533107fc in do_ext_nconf crypto/x509v3/v3_conf.c:100
    openssl#11 0x7f2653310f33 in X509V3_EXT_nconf crypto/x509v3/v3_conf.c:45
    openssl#12 0x7f2653311426 in X509V3_EXT_add_nconf_sk crypto/x509v3/v3_conf.c:312
    openssl#13 0x7f265331170c in X509V3_EXT_REQ_add_nconf crypto/x509v3/v3_conf.c:360
    openssl#14 0x564ed19d5f25 in req_main apps/req.c:806
    openssl#15 0x564ed19b8de0 in do_cmd apps/openssl.c:564
    openssl#16 0x564ed1985165 in main apps/openssl.c:183
    openssl#17 0x7f2651c4a082 in __libc_start_main ../csu/libc-start.c:308
    openssl#18 0x564ed1985acd in _start (/home/ed/OPCToolboxV5/Source/Core/OpenSSL/openssl/apps/openssl+0x139acd)

0x603000073280 is located 16 bytes inside of 24-byte region [0x603000073270,0x603000073288)
freed by thread T0 here:
    #0 0x7f265413440f in __interceptor_free ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:122
    openssl#1 0x7f265315a429 in CRYPTO_free crypto/mem.c:311
    openssl#2 0x7f265315a429 in CRYPTO_free crypto/mem.c:300
    openssl#3 0x7f2652e757b9 in ASN1_mbstring_ncopy crypto/asn1/a_mbstr.c:191
    openssl#4 0x7f2652e75ec5 in ASN1_mbstring_copy crypto/asn1/a_mbstr.c:38
    openssl#5 0x7f2652e8e227 in asn1_str2type crypto/asn1/asn1_gen.c:681
    openssl#6 0x7f2652e8e227 in generate_v3 crypto/asn1/asn1_gen.c:137
    openssl#7 0x7f2652e9166c in ASN1_generate_v3 crypto/asn1/asn1_gen.c:92
    openssl#8 0x7f2653307b9b in do_othername crypto/x509v3/v3_alt.c:577
    openssl#9 0x7f2653307b9b in a2i_GENERAL_NAME crypto/x509v3/v3_alt.c:492
    openssl#10 0x7f26533087c2 in v2i_subject_alt crypto/x509v3/v3_alt.c:327
    openssl#11 0x7f26533107fc in do_ext_nconf crypto/x509v3/v3_conf.c:100
    openssl#12 0x7f2653310f33 in X509V3_EXT_nconf crypto/x509v3/v3_conf.c:45
    openssl#13 0x7f2653311426 in X509V3_EXT_add_nconf_sk crypto/x509v3/v3_conf.c:312
    openssl#14 0x7f265331170c in X509V3_EXT_REQ_add_nconf crypto/x509v3/v3_conf.c:360
    openssl#15 0x564ed19d5f25 in req_main apps/req.c:806
    openssl#16 0x564ed19b8de0 in do_cmd apps/openssl.c:564
    openssl#17 0x564ed1985165 in main apps/openssl.c:183
    openssl#18 0x7f2651c4a082 in __libc_start_main ../csu/libc-start.c:308

previously allocated by thread T0 here:
    #0 0x7f2654134808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    openssl#1 0x7f265315a4fd in CRYPTO_malloc crypto/mem.c:221
    openssl#2 0x7f265315a4fd in CRYPTO_malloc crypto/mem.c:198
    openssl#3 0x7f265315a945 in CRYPTO_zalloc crypto/mem.c:236
    openssl#4 0x7f2652e939a4 in ASN1_STRING_type_new crypto/asn1/asn1_lib.c:341
    openssl#5 0x7f2652e74e51 in ASN1_mbstring_ncopy crypto/asn1/a_mbstr.c:150
    openssl#6 0x7f2652e75ec5 in ASN1_mbstring_copy crypto/asn1/a_mbstr.c:38
    openssl#7 0x7f2652e8e227 in asn1_str2type crypto/asn1/asn1_gen.c:681
    openssl#8 0x7f2652e8e227 in generate_v3 crypto/asn1/asn1_gen.c:137
    openssl#9 0x7f2652e9166c in ASN1_generate_v3 crypto/asn1/asn1_gen.c:92
    openssl#10 0x7f2653307b9b in do_othername crypto/x509v3/v3_alt.c:577
    openssl#11 0x7f2653307b9b in a2i_GENERAL_NAME crypto/x509v3/v3_alt.c:492
    openssl#12 0x7f26533087c2 in v2i_subject_alt crypto/x509v3/v3_alt.c:327
    openssl#13 0x7f26533107fc in do_ext_nconf crypto/x509v3/v3_conf.c:100
    openssl#14 0x7f2653310f33 in X509V3_EXT_nconf crypto/x509v3/v3_conf.c:45
    openssl#15 0x7f2653311426 in X509V3_EXT_add_nconf_sk crypto/x509v3/v3_conf.c:312
    openssl#16 0x7f265331170c in X509V3_EXT_REQ_add_nconf crypto/x509v3/v3_conf.c:360
    openssl#17 0x564ed19d5f25 in req_main apps/req.c:806
    openssl#18 0x564ed19b8de0 in do_cmd apps/openssl.c:564
    openssl#19 0x564ed1985165 in main apps/openssl.c:183
    openssl#20 0x7f2651c4a082 in __libc_start_main ../csu/libc-start.c:308
bernd-edlinger added a commit to bernd-edlinger/openssl that referenced this pull request Jan 5, 2024
Sometimes the error handling returns an ASN1_STRING
object in *out although that was not passed in by the
caller, and sometimes the error handling deletes the
ASN1_STRING but forgets to clear the *out parameter.
Therefore the caller has no chance to know, if the leaked
object in *out shall be deleted or not.
This may cause a use-after-free error e.g. in asn1_str2type:

==63312==ERROR: AddressSanitizer: heap-use-after-free on address 0x603000073280 at pc 0x7f2652e93b08 bp 0x7ffe0e1951c0 sp 0x7ffe0e1951b0
READ of size 8 at 0x603000073280 thread T0
    #0 0x7f2652e93b07 in asn1_string_embed_free crypto/asn1/asn1_lib.c:354
    openssl#1 0x7f2652eb521a in asn1_primitive_free crypto/asn1/tasn_fre.c:204
    openssl#2 0x7f2652eb50a9 in asn1_primitive_free crypto/asn1/tasn_fre.c:199
    openssl#3 0x7f2652eb5b67 in ASN1_item_free crypto/asn1/tasn_fre.c:20
    openssl#4 0x7f2652e8e13b in asn1_str2type crypto/asn1/asn1_gen.c:740
    openssl#5 0x7f2652e8e13b in generate_v3 crypto/asn1/asn1_gen.c:137
    openssl#6 0x7f2652e9166c in ASN1_generate_v3 crypto/asn1/asn1_gen.c:92
    openssl#7 0x7f2653307b9b in do_othername crypto/x509v3/v3_alt.c:577
    openssl#8 0x7f2653307b9b in a2i_GENERAL_NAME crypto/x509v3/v3_alt.c:492
    openssl#9 0x7f26533087c2 in v2i_subject_alt crypto/x509v3/v3_alt.c:327
    openssl#10 0x7f26533107fc in do_ext_nconf crypto/x509v3/v3_conf.c:100
    openssl#11 0x7f2653310f33 in X509V3_EXT_nconf crypto/x509v3/v3_conf.c:45
    openssl#12 0x7f2653311426 in X509V3_EXT_add_nconf_sk crypto/x509v3/v3_conf.c:312
    openssl#13 0x7f265331170c in X509V3_EXT_REQ_add_nconf crypto/x509v3/v3_conf.c:360
    openssl#14 0x564ed19d5f25 in req_main apps/req.c:806
    openssl#15 0x564ed19b8de0 in do_cmd apps/openssl.c:564
    openssl#16 0x564ed1985165 in main apps/openssl.c:183
    openssl#17 0x7f2651c4a082 in __libc_start_main ../csu/libc-start.c:308
    openssl#18 0x564ed1985acd in _start (/home/ed/OPCToolboxV5/Source/Core/OpenSSL/openssl/apps/openssl+0x139acd)

0x603000073280 is located 16 bytes inside of 24-byte region [0x603000073270,0x603000073288)
freed by thread T0 here:
    #0 0x7f265413440f in __interceptor_free ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:122
    openssl#1 0x7f265315a429 in CRYPTO_free crypto/mem.c:311
    openssl#2 0x7f265315a429 in CRYPTO_free crypto/mem.c:300
    openssl#3 0x7f2652e757b9 in ASN1_mbstring_ncopy crypto/asn1/a_mbstr.c:191
    openssl#4 0x7f2652e75ec5 in ASN1_mbstring_copy crypto/asn1/a_mbstr.c:38
    openssl#5 0x7f2652e8e227 in asn1_str2type crypto/asn1/asn1_gen.c:681
    openssl#6 0x7f2652e8e227 in generate_v3 crypto/asn1/asn1_gen.c:137
    openssl#7 0x7f2652e9166c in ASN1_generate_v3 crypto/asn1/asn1_gen.c:92
    openssl#8 0x7f2653307b9b in do_othername crypto/x509v3/v3_alt.c:577
    openssl#9 0x7f2653307b9b in a2i_GENERAL_NAME crypto/x509v3/v3_alt.c:492
    openssl#10 0x7f26533087c2 in v2i_subject_alt crypto/x509v3/v3_alt.c:327
    openssl#11 0x7f26533107fc in do_ext_nconf crypto/x509v3/v3_conf.c:100
    openssl#12 0x7f2653310f33 in X509V3_EXT_nconf crypto/x509v3/v3_conf.c:45
    openssl#13 0x7f2653311426 in X509V3_EXT_add_nconf_sk crypto/x509v3/v3_conf.c:312
    openssl#14 0x7f265331170c in X509V3_EXT_REQ_add_nconf crypto/x509v3/v3_conf.c:360
    openssl#15 0x564ed19d5f25 in req_main apps/req.c:806
    openssl#16 0x564ed19b8de0 in do_cmd apps/openssl.c:564
    openssl#17 0x564ed1985165 in main apps/openssl.c:183
    openssl#18 0x7f2651c4a082 in __libc_start_main ../csu/libc-start.c:308

previously allocated by thread T0 here:
    #0 0x7f2654134808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    openssl#1 0x7f265315a4fd in CRYPTO_malloc crypto/mem.c:221
    openssl#2 0x7f265315a4fd in CRYPTO_malloc crypto/mem.c:198
    openssl#3 0x7f265315a945 in CRYPTO_zalloc crypto/mem.c:236
    openssl#4 0x7f2652e939a4 in ASN1_STRING_type_new crypto/asn1/asn1_lib.c:341
    openssl#5 0x7f2652e74e51 in ASN1_mbstring_ncopy crypto/asn1/a_mbstr.c:150
    openssl#6 0x7f2652e75ec5 in ASN1_mbstring_copy crypto/asn1/a_mbstr.c:38
    openssl#7 0x7f2652e8e227 in asn1_str2type crypto/asn1/asn1_gen.c:681
    openssl#8 0x7f2652e8e227 in generate_v3 crypto/asn1/asn1_gen.c:137
    openssl#9 0x7f2652e9166c in ASN1_generate_v3 crypto/asn1/asn1_gen.c:92
    openssl#10 0x7f2653307b9b in do_othername crypto/x509v3/v3_alt.c:577
    openssl#11 0x7f2653307b9b in a2i_GENERAL_NAME crypto/x509v3/v3_alt.c:492
    openssl#12 0x7f26533087c2 in v2i_subject_alt crypto/x509v3/v3_alt.c:327
    openssl#13 0x7f26533107fc in do_ext_nconf crypto/x509v3/v3_conf.c:100
    openssl#14 0x7f2653310f33 in X509V3_EXT_nconf crypto/x509v3/v3_conf.c:45
    openssl#15 0x7f2653311426 in X509V3_EXT_add_nconf_sk crypto/x509v3/v3_conf.c:312
    openssl#16 0x7f265331170c in X509V3_EXT_REQ_add_nconf crypto/x509v3/v3_conf.c:360
    openssl#17 0x564ed19d5f25 in req_main apps/req.c:806
    openssl#18 0x564ed19b8de0 in do_cmd apps/openssl.c:564
    openssl#19 0x564ed1985165 in main apps/openssl.c:183
    openssl#20 0x7f2651c4a082 in __libc_start_main ../csu/libc-start.c:308

Reviewed-by: Paul Yang <kaishen.yy@antfin.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl#23138)

(cherry picked from commit 73ebaac)
wbeck10 pushed a commit to wbeck10/openssl that referenced this pull request Jan 8, 2024
Sometimes the error handling returns an ASN1_STRING
object in *out although that was not passed in by the
caller, and sometimes the error handling deletes the
ASN1_STRING but forgets to clear the *out parameter.
Therefore the caller has no chance to know, if the leaked
object in *out shall be deleted or not.
This may cause a use-after-free error e.g. in asn1_str2type:

==63312==ERROR: AddressSanitizer: heap-use-after-free on address 0x603000073280 at pc 0x7f2652e93b08 bp 0x7ffe0e1951c0 sp 0x7ffe0e1951b0
READ of size 8 at 0x603000073280 thread T0
    #0 0x7f2652e93b07 in asn1_string_embed_free crypto/asn1/asn1_lib.c:354
    openssl#1 0x7f2652eb521a in asn1_primitive_free crypto/asn1/tasn_fre.c:204
    openssl#2 0x7f2652eb50a9 in asn1_primitive_free crypto/asn1/tasn_fre.c:199
    openssl#3 0x7f2652eb5b67 in ASN1_item_free crypto/asn1/tasn_fre.c:20
    openssl#4 0x7f2652e8e13b in asn1_str2type crypto/asn1/asn1_gen.c:740
    openssl#5 0x7f2652e8e13b in generate_v3 crypto/asn1/asn1_gen.c:137
    openssl#6 0x7f2652e9166c in ASN1_generate_v3 crypto/asn1/asn1_gen.c:92
    openssl#7 0x7f2653307b9b in do_othername crypto/x509v3/v3_alt.c:577
    openssl#8 0x7f2653307b9b in a2i_GENERAL_NAME crypto/x509v3/v3_alt.c:492
    openssl#9 0x7f26533087c2 in v2i_subject_alt crypto/x509v3/v3_alt.c:327
    openssl#10 0x7f26533107fc in do_ext_nconf crypto/x509v3/v3_conf.c:100
    openssl#11 0x7f2653310f33 in X509V3_EXT_nconf crypto/x509v3/v3_conf.c:45
    openssl#12 0x7f2653311426 in X509V3_EXT_add_nconf_sk crypto/x509v3/v3_conf.c:312
    openssl#13 0x7f265331170c in X509V3_EXT_REQ_add_nconf crypto/x509v3/v3_conf.c:360
    openssl#14 0x564ed19d5f25 in req_main apps/req.c:806
    openssl#15 0x564ed19b8de0 in do_cmd apps/openssl.c:564
    openssl#16 0x564ed1985165 in main apps/openssl.c:183
    openssl#17 0x7f2651c4a082 in __libc_start_main ../csu/libc-start.c:308
    openssl#18 0x564ed1985acd in _start (/home/ed/OPCToolboxV5/Source/Core/OpenSSL/openssl/apps/openssl+0x139acd)

0x603000073280 is located 16 bytes inside of 24-byte region [0x603000073270,0x603000073288)
freed by thread T0 here:
    #0 0x7f265413440f in __interceptor_free ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:122
    openssl#1 0x7f265315a429 in CRYPTO_free crypto/mem.c:311
    openssl#2 0x7f265315a429 in CRYPTO_free crypto/mem.c:300
    openssl#3 0x7f2652e757b9 in ASN1_mbstring_ncopy crypto/asn1/a_mbstr.c:191
    openssl#4 0x7f2652e75ec5 in ASN1_mbstring_copy crypto/asn1/a_mbstr.c:38
    openssl#5 0x7f2652e8e227 in asn1_str2type crypto/asn1/asn1_gen.c:681
    openssl#6 0x7f2652e8e227 in generate_v3 crypto/asn1/asn1_gen.c:137
    openssl#7 0x7f2652e9166c in ASN1_generate_v3 crypto/asn1/asn1_gen.c:92
    openssl#8 0x7f2653307b9b in do_othername crypto/x509v3/v3_alt.c:577
    openssl#9 0x7f2653307b9b in a2i_GENERAL_NAME crypto/x509v3/v3_alt.c:492
    openssl#10 0x7f26533087c2 in v2i_subject_alt crypto/x509v3/v3_alt.c:327
    openssl#11 0x7f26533107fc in do_ext_nconf crypto/x509v3/v3_conf.c:100
    openssl#12 0x7f2653310f33 in X509V3_EXT_nconf crypto/x509v3/v3_conf.c:45
    openssl#13 0x7f2653311426 in X509V3_EXT_add_nconf_sk crypto/x509v3/v3_conf.c:312
    openssl#14 0x7f265331170c in X509V3_EXT_REQ_add_nconf crypto/x509v3/v3_conf.c:360
    openssl#15 0x564ed19d5f25 in req_main apps/req.c:806
    openssl#16 0x564ed19b8de0 in do_cmd apps/openssl.c:564
    openssl#17 0x564ed1985165 in main apps/openssl.c:183
    openssl#18 0x7f2651c4a082 in __libc_start_main ../csu/libc-start.c:308

previously allocated by thread T0 here:
    #0 0x7f2654134808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    openssl#1 0x7f265315a4fd in CRYPTO_malloc crypto/mem.c:221
    openssl#2 0x7f265315a4fd in CRYPTO_malloc crypto/mem.c:198
    openssl#3 0x7f265315a945 in CRYPTO_zalloc crypto/mem.c:236
    openssl#4 0x7f2652e939a4 in ASN1_STRING_type_new crypto/asn1/asn1_lib.c:341
    openssl#5 0x7f2652e74e51 in ASN1_mbstring_ncopy crypto/asn1/a_mbstr.c:150
    openssl#6 0x7f2652e75ec5 in ASN1_mbstring_copy crypto/asn1/a_mbstr.c:38
    openssl#7 0x7f2652e8e227 in asn1_str2type crypto/asn1/asn1_gen.c:681
    openssl#8 0x7f2652e8e227 in generate_v3 crypto/asn1/asn1_gen.c:137
    openssl#9 0x7f2652e9166c in ASN1_generate_v3 crypto/asn1/asn1_gen.c:92
    openssl#10 0x7f2653307b9b in do_othername crypto/x509v3/v3_alt.c:577
    openssl#11 0x7f2653307b9b in a2i_GENERAL_NAME crypto/x509v3/v3_alt.c:492
    openssl#12 0x7f26533087c2 in v2i_subject_alt crypto/x509v3/v3_alt.c:327
    openssl#13 0x7f26533107fc in do_ext_nconf crypto/x509v3/v3_conf.c:100
    openssl#14 0x7f2653310f33 in X509V3_EXT_nconf crypto/x509v3/v3_conf.c:45
    openssl#15 0x7f2653311426 in X509V3_EXT_add_nconf_sk crypto/x509v3/v3_conf.c:312
    openssl#16 0x7f265331170c in X509V3_EXT_REQ_add_nconf crypto/x509v3/v3_conf.c:360
    openssl#17 0x564ed19d5f25 in req_main apps/req.c:806
    openssl#18 0x564ed19b8de0 in do_cmd apps/openssl.c:564
    openssl#19 0x564ed1985165 in main apps/openssl.c:183
    openssl#20 0x7f2651c4a082 in __libc_start_main ../csu/libc-start.c:308

Reviewed-by: Paul Yang <kaishen.yy@antfin.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl#23138)
rschu1ze added a commit to ClickHouse/openssl that referenced this pull request Mar 20, 2024
-----

E           Exception: Sanitizer assert found for instance ==================
E           WARNING: ThreadSanitizer: data race (pid=1)
E             Write of size 8 at 0x7b2800025d30 by thread T2 (mutexes: write M0, write M1):
E               #0 free <null> (clickhouse+0x709a3e5) (BuildId: 706d92b17db171493f293d517643f726ee1b7b1e)
E               #1 CRYPTO_free build_docker/./contrib/openssl/crypto/mem.c:282:5 (clickhouse+0x2015f8ea) (BuildId: 706d92b17db171493f293d517643f726ee1b7b1e)
E               #2 EVP_PKEY_free build_docker/./contrib/openssl/crypto/evp/p_lib.c:1809:5 (clickhouse+0x2012a751) (BuildId: 706d92b17db171493f293d517643f726ee1b7b1e)
E               #3 Poco::Crypto::EVPPKey::~EVPPKey() build_docker/./base/poco/Crypto/src/EVPPKey.cpp:121:17 (clickhouse+0x1d00ffa9) (BuildId: 706d92b17db171493f293d517643f726ee1b7b1e)
E               #4 DB::CertificateReloader::Data::~Data() build_docker/./src/Server/CertificateReloader.h:71:12 (clickhouse+0x194fb42d) (BuildId: 706d92b17db171493f293d517643f726ee1b7b1e)
E               #5 std::__1::default_delete<DB::CertificateReloader::Data const>::operator()[abi:v15000](DB::CertificateReloader::Data const*) const build_docker/./contrib/llvm-project/libcxx/include/__memory/unique_ptr.h:48:5 (clickhouse+0x194fb42d)
E               #6 std::__1::__shared_ptr_pointer<DB::CertificateReloader::Data const*, std::__1::default_delete<DB::CertificateReloader::Data const>, std::__1::allocator<DB::CertificateReloader::Data const>>::__on_zero_shared() build_docker/./contrib/llvm-project/libcxx/include/__memory/shared_ptr.h:263:5 (clickhouse+0x194fb42d)
E               #7 std::__1::__shared_count::__release_shared[abi:v15000]() build_docker/./contrib/llvm-project/libcxx/include/__memory/shared_ptr.h:174:9 (clickhouse+0x194fade0) (BuildId: 706d92b17db171493f293d517643f726ee1b7b1e)
E               #8 std::__1::__shared_weak_count::__release_shared[abi:v15000]() build_docker/./contrib/llvm-project/libcxx/include/__memory/shared_ptr.h:215:27 (clickhouse+0x194fade0)
E               openssl#9 std::__1::shared_ptr<DB::CertificateReloader::Data const>::~shared_ptr[abi:v15000]() build_docker/./contrib/llvm-project/libcxx/include/__memory/shared_ptr.h:702:23 (clickhouse+0x194fade0)
E               openssl#10 std::__1::shared_ptr<DB::CertificateReloader::Data const>::operator=[abi:v15000](std::__1::shared_ptr<DB::CertificateReloader::Data const>&&) build_docker/./contrib/llvm-project/libcxx/include/__memory/shared_ptr.h:723:9 (clickhouse+0x194fade0)
E               openssl#11 MultiVersion<DB::CertificateReloader::Data>::set(std::__1::unique_ptr<DB::CertificateReloader::Data const, std::__1::default_delete<DB::CertificateReloader::Data const>>&&) build_docker/./src/Common/MultiVersion.h:76:25 (clickhouse+0x194fade0)
E               openssl#12 DB::CertificateReloader::tryLoad(Poco::Util::AbstractConfiguration const&) build_docker/./src/Server/CertificateReloader.cpp:83:18 (clickhouse+0x194f94ca) (BuildId: 706d92b17db171493f293d517643f726ee1b7b1e)
E               openssl#13 DB::Server::main(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&)::$_6::operator()(Poco::AutoPtr<Poco::Util::AbstractConfiguration>, bool) const build_docker/./programs/server/Server.cpp:1546:45 (clickhouse+0xf384df7) (BuildId: 706d92b17db171493f293d517643f726ee1b7b1e)
E               openssl#14 decltype(std::declval<DB::Server::main(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&)::$_6&>()(std::declval<Poco::AutoPtr<Poco::Util::AbstractConfiguration>>(), std::declval<bool>())) std::__1::__invoke[abi:v15000]<DB::Server::main(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&)::$_6&, Poco::AutoPtr<Poco::Util::AbstractConfiguration>, bool>(DB::Server::main(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&)::$_6&, Poco::AutoPtr<Poco::Util::AbstractConfiguration>&&, bool&&) build_docker/./contrib/llvm-project/libcxx/include/__functional/invoke.h:394:23 (clickhouse+0xf3827a9) (BuildId: 706d92b17db171493f293d517643f726ee1b7b1e)
E               openssl#15 void std::__1::__invoke_void_return_wrapper<void, true>::__call<DB::Server::main(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&)::$_6&, Poco::AutoPtr<Poco::Util::AbstractConfiguration>, bool>(DB::Server::main(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&)::$_6&, Poco::AutoPtr<Poco::Util::AbstractConfiguration>&&, bool&&) build_docker/./contrib/llvm-project/libcxx/include/__functional/invoke.h:479:9 (clickhouse+0xf3827a9)
E               openssl#16 std::__1::__function::__default_alloc_func<DB::Server::main(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&)::$_6, void (Poco::AutoPtr<Poco::Util::AbstractConfiguration>, bool)>::operator()[abi:v15000](Poco::AutoPtr<Poco::Util::AbstractConfiguration>&&, bool&&) build_docker/./contrib/llvm-project/libcxx/include/__functional/function.h:235:12 (clickhouse+0xf3827a9)
E               openssl#17 void std::__1::__function::__policy_invoker<void (Poco::AutoPtr<Poco::Util::AbstractConfiguration>, bool)>::__call_impl<std::__1::__function::__default_alloc_func<DB::Server::main(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&)::$_6, void (Poco::AutoPtr<Poco::Util::AbstractConfiguration>, bool)>>(std::__1::__function::__policy_storage const*, Poco::AutoPtr<Poco::Util::AbstractConfiguration>&&, bool) build_docker/./contrib/llvm-project/libcxx/include/__functional/function.h:716:16 (clickhouse+0xf3827a9)
E               openssl#18 std::__1::__function::__policy_func<void (Poco::AutoPtr<Poco::Util::AbstractConfiguration>, bool)>::operator()[abi:v15000](Poco::AutoPtr<Poco::Util::AbstractConfiguration>&&, bool&&) const build_docker/./contrib/llvm-project/libcxx/include/__functional/function.h:848:16 (clickhouse+0x19fd2cbe) (BuildId: 706d92b17db171493f293d517643f726ee1b7b1e)
E               openssl#19 std::__1::function<void (Poco::AutoPtr<Poco::Util::AbstractConfiguration>, bool)>::operator()(Poco::AutoPtr<Poco::Util::AbstractConfiguration>, bool) const build_docker/./contrib/llvm-project/libcxx/include/__functional/function.h:1187:12 (clickhouse+0x19fd2cbe)
E               openssl#20 DB::ConfigReloader::reloadIfNewer(bool, bool, bool, bool) build_docker/./src/Common/Config/ConfigReloader.cpp:150:13 (clickhouse+0x19fd2cbe)
E               openssl#21 DB::ConfigReloader::reload() build_docker/./src/Common/Config/ConfigReloader.h:51:21 (clickhouse+0xf38767c) (BuildId: 706d92b17db171493f293d517643f726ee1b7b1e)
E               openssl#22 DB::Server::main(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&)::$_13::operator()() const build_docker/./programs/server/Server.cpp:1731:31 (clickhouse+0xf38767c)
E               openssl#23 decltype(std::declval<DB::Server::main(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&)::$_13&>()()) std::__1::__invoke[abi:v15000]<DB::Server::main(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&)::$_13&>(DB::Server::main(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&)::$_13&) build_docker/./contrib/llvm-project/libcxx/include/__functional/invoke.h:394:23 (clickhouse+0xf38767c)
E               openssl#24 void std::__1::__invoke_void_return_wrapper<void, true>::__call<DB::Server::main(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&)::$_13&>(DB::Server::main(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&)::$_13&) build_docker/./contrib/llvm-project/libcxx/include/__functional/invoke.h:479:9 (clickhouse+0xf38767c)
E               openssl#25 std::__1::__function::__default_alloc_func<DB::Server::main(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&)::$_13, void ()>::operator()[abi:v15000]() build_docker/./contrib/llvm-project/libcxx/include/__functional/function.h:235:12 (clickhouse+0xf38767c)
E               openssl#26 void std::__1::__function::__policy_invoker<void ()>::__call_impl<std::__1::__function::__default_alloc_func<DB::Server::main(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&)::$_13, void ()>>(std::__1::__function::__policy_storage const*) build_docker/./contrib/llvm-project/libcxx/include/__functional/function.h:716:16 (clickhouse+0xf38767c)
E               openssl#27 std::__1::__function::__policy_func<void ()>::operator()[abi:v15000]() const build_docker/./contrib/llvm-project/libcxx/include/__functional/function.h:848:16 (clickhouse+0x16907aa0) (BuildId: 706d92b17db171493f293d517643f726ee1b7b1e)
E               openssl#28 std::__1::function<void ()>::operator()() const build_docker/./contrib/llvm-project/libcxx/include/__functional/function.h:1187:12 (clickhouse+0x16907aa0)
E               openssl#29 DB::Context::reloadConfig() const build_docker/./src/Interpreters/Context.cpp:4357:5 (clickhouse+0x16907aa0)
E               openssl#30 DB::InterpreterSystemQuery::execute() build_docker/./src/Interpreters/InterpreterSystemQuery.cpp:577:29 (clickhouse+0x17e78c19) (BuildId: 706d92b17db171493f293d517643f726ee1b7b1e)
E               openssl#31 DB::executeQueryImpl(char const*, char const*, std::__1::shared_ptr<DB::Context>, DB::QueryFlags, DB::QueryProcessingStage::Enum, DB::ReadBuffer*) build_docker/./src/Interpreters/executeQuery.cpp:1195:40 (clickhouse+0x17e3e462) (BuildId: 706d92b17db171493f293d517643f726ee1b7b1e)
E               openssl#32 DB::executeQuery(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::shared_ptr<DB::Context>, DB::QueryFlags, DB::QueryProcessingStage::Enum) build_docker/./src/Interpreters/executeQuery.cpp:1374:26 (clickhouse+0x17e39837) (BuildId: 706d92b17db171493f293d517643f726ee1b7b1e)
E               openssl#33 DB::TCPHandler::runImpl() build_docker/./src/Server/TCPHandler.cpp:518:54 (clickhouse+0x195cc651) (BuildId: 706d92b17db171493f293d517643f726ee1b7b1e)
E               openssl#34 DB::TCPHandler::run() build_docker/./src/Server/TCPHandler.cpp:2329:9 (clickhouse+0x195e8707) (BuildId: 706d92b17db171493f293d517643f726ee1b7b1e)
E               openssl#35 Poco::Net::TCPServerConnection::start() build_docker/./base/poco/Net/src/TCPServerConnection.cpp:43:3 (clickhouse+0x1d00d942) (BuildId: 706d92b17db171493f293d517643f726ee1b7b1e)
E               openssl#36 Poco::Net::TCPServerDispatcher::run() build_docker/./base/poco/Net/src/TCPServerDispatcher.cpp:115:20 (clickhouse+0x1d00e1b1) (BuildId: 706d92b17db171493f293d517643f726ee1b7b1e)
E               openssl#37 Poco::PooledThread::run() build_docker/./base/poco/Foundation/src/ThreadPool.cpp:188:14 (clickhouse+0x1d20f2e6) (BuildId: 706d92b17db171493f293d517643f726ee1b7b1e)
E               openssl#38 Poco::(anonymous namespace)::RunnableHolder::run() build_docker/./base/poco/Foundation/src/Thread.cpp:45:11 (clickhouse+0x1d20d5af) (BuildId: 706d92b17db171493f293d517643f726ee1b7b1e)
E               openssl#39 Poco::ThreadImpl::runnableEntry(void*) build_docker/./base/poco/Foundation/src/Thread_POSIX.cpp:335:27 (clickhouse+0x1d20ba69) (BuildId: 706d92b17db171493f293d517643f726ee1b7b1e)
E
E             Previous atomic write of size 4 at 0x7b2800025d30 by thread T3 (mutexes: write M2):
E               #0 CRYPTO_DOWN_REF build_docker/./contrib/openssl/include/internal/refcount.h:51:12 (clickhouse+0x2012a6e6) (BuildId: 706d92b17db171493f293d517643f726ee1b7b1e)
E               #1 EVP_PKEY_free build_docker/./contrib/openssl/crypto/evp/p_lib.c:1795:5 (clickhouse+0x2012a6e6)
E               #2 ssl_cert_clear_certs build_docker/./contrib/openssl/ssl/ssl_cert.c:246:9 (clickhouse+0x1ffafd37) (BuildId: 706d92b17db171493f293d517643f726ee1b7b1e)
E               #3 ssl_cert_free build_docker/./contrib/openssl/ssl/ssl_cert.c:277:5 (clickhouse+0x1ffafd37)
E               #4 ossl_ssl_connection_free build_docker/./contrib/openssl/ssl/ssl_lib.c:1458:5 (clickhouse+0x1ffba6af) (BuildId: 706d92b17db171493f293d517643f726ee1b7b1e)
E               #5 SSL_free build_docker/./contrib/openssl/ssl/ssl_lib.c:1417:9 (clickhouse+0x1ffb920e) (BuildId: 706d92b17db171493f293d517643f726ee1b7b1e)
E               #6 Poco::Net::SecureSocketImpl::reset() build_docker/./base/poco/NetSSL_OpenSSL/src/SecureSocketImpl.cpp:583:3 (clickhouse+0x1cfaac60) (BuildId: 706d92b17db171493f293d517643f726ee1b7b1e)
E               #7 Poco::Net::SecureSocketImpl::~SecureSocketImpl() build_docker/./base/poco/NetSSL_OpenSSL/src/SecureSocketImpl.cpp:80:3 (clickhouse+0x1cfaac60)
E               #8 Poco::Net::SecureStreamSocketImpl::~SecureStreamSocketImpl() build_docker/./base/poco/NetSSL_OpenSSL/src/SecureStreamSocketImpl.cpp:52:1 (clickhouse+0x1cfb15dd) (BuildId: 706d92b17db171493f293d517643f726ee1b7b1e)
E               openssl#9 Poco::Net::SecureStreamSocketImpl::~SecureStreamSocketImpl() build_docker/./base/poco/NetSSL_OpenSSL/src/SecureStreamSocketImpl.cpp:43:1 (clickhouse+0x1cfb15dd)
E               openssl#10 Poco::RefCountedObject::release() const build_docker/./base/poco/Foundation/include/Poco/RefCountedObject.h:86:13 (clickhouse+0x1cffc81e) (BuildId: 706d92b17db171493f293d517643f726ee1b7b1e)
E               openssl#11 Poco::Net::Socket::~Socket() build_docker/./base/poco/Net/src/Socket.cpp:68:10 (clickhouse+0x1cffc81e)
E               openssl#12 Poco::Net::StreamSocket::~StreamSocket() build_docker/./base/poco/Net/src/StreamSocket.cpp:63:1 (clickhouse+0x1d009c39) (BuildId: 706d92b17db171493f293d517643f726ee1b7b1e)
E               openssl#13 Poco::Net::TCPConnectionNotification::~TCPConnectionNotification() build_docker/./base/poco/Net/src/TCPServerDispatcher.cpp:43:2 (clickhouse+0x1d00ef50) (BuildId: 706d92b17db171493f293d517643f726ee1b7b1e)
E               openssl#14 Poco::Net::TCPConnectionNotification::~TCPConnectionNotification() build_docker/./base/poco/Net/src/TCPServerDispatcher.cpp:42:2 (clickhouse+0x1d00ef50)
E               openssl#15 Poco::RefCountedObject::release() const build_docker/./base/poco/Foundation/include/Poco/RefCountedObject.h:86:13 (clickhouse+0x1d00e203) (BuildId: 706d92b17db171493f293d517643f726ee1b7b1e)
E               openssl#16 Poco::AutoPtr<Poco::Notification>::~AutoPtr() build_docker/./base/poco/Foundation/include/Poco/AutoPtr.h:91:19 (clickhouse+0x1d00e203)
E               openssl#17 Poco::Net::TCPServerDispatcher::run() build_docker/./base/poco/Net/src/TCPServerDispatcher.cpp:122:3 (clickhouse+0x1d00e203)
E               openssl#18 Poco::PooledThread::run() build_docker/./base/poco/Foundation/src/ThreadPool.cpp:188:14 (clickhouse+0x1d20f2e6) (BuildId: 706d92b17db171493f293d517643f726ee1b7b1e)
E               openssl#19 Poco::(anonymous namespace)::RunnableHolder::run() build_docker/./base/poco/Foundation/src/Thread.cpp:45:11 (clickhouse+0x1d20d5af) (BuildId: 706d92b17db171493f293d517643f726ee1b7b1e)
E               openssl#20 Poco::ThreadImpl::runnableEntry(void*) build_docker/./base/poco/Foundation/src/Thread_POSIX.cpp:335:27 (clickhouse+0x1d20ba69) (BuildId: 706d92b17db171493f293d517643f726ee1b7b1e)
rschu1ze added a commit to ClickHouse/openssl that referenced this pull request Apr 29, 2024
The following issue was found in automatic tests with thread sanitizer
builds in ClickHouse (which uses OpenSSL 3.2.1):

The first stack does proper locking (function 'x509_store_add',
x509_lu.c) but in the second stack, function 'get_cert_by_subject_ex'
(by_dir.b) forgets to lock when calling 'sk_X509_OBJECT_is_sorted'.

```
WARNING: ThreadSanitizer: data race (pid=1870)
  Write of size 4 at 0x7b08003d6810 by thread T552 (mutexes: write M0, write M1, write M2, write M3):
    #0 OPENSSL_sk_insert build_docker/./contrib/openssl/crypto/stack/stack.c:280:16 (clickhouse+0x203ad7e4) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #1 OPENSSL_sk_push build_docker/./contrib/openssl/crypto/stack/stack.c:401:12 (clickhouse+0x203ad7e4)
    #2 x509_store_add build_docker/./contrib/openssl/crypto/x509/x509_lu.c:419:17 (clickhouse+0x203d4a52) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #3 X509_STORE_add_cert build_docker/./contrib/openssl/crypto/x509/x509_lu.c:432:10 (clickhouse+0x203d48a2) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #4 X509_load_cert_file_ex build_docker/./contrib/openssl/crypto/x509/by_file.c:127:18 (clickhouse+0x203b74e6) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #5 get_cert_by_subject_ex build_docker/./contrib/openssl/crypto/x509/by_dir.c:333:22 (clickhouse+0x203b684c) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #6 X509_LOOKUP_by_subject_ex build_docker/./contrib/openssl/crypto/x509/x509_lu.c:105:16 (clickhouse+0x203d46ec) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #7 ossl_x509_store_ctx_get_by_subject build_docker/./contrib/openssl/crypto/x509/x509_lu.c:360:17 (clickhouse+0x203d46ec)
    #8 X509_STORE_CTX_get1_issuer build_docker/./contrib/openssl/crypto/x509/x509_lu.c:782:10 (clickhouse+0x203d56cb) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#9 get1_trusted_issuer build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:3194:10 (clickhouse+0x203db4a9) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#10 build_chain build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:3324:40 (clickhouse+0x203db4a9)
    openssl#11 verify_chain build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:240:15 (clickhouse+0x203dbe27) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#12 x509_verify_x509 build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:358 (clickhouse+0x203d7fd8) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#13 X509_verify_cert build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:293:56 (clickhouse+0x203d8215) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#14 ssl_verify_internal build_docker/./contrib/openssl/ssl/ssl_cert.c:496:13 (clickhouse+0x2019a2a4) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#15 ssl_verify_cert_chain build_docker/./contrib/openssl/ssl/ssl_cert.c:543:12 (clickhouse+0x2019a402) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#16 tls_post_process_server_certificate build_docker/./contrib/openssl/ssl/statem/statem_clnt.c:2072:9 (clickhouse+0x20227658) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#17 ossl_statem_client_post_process_message build_docker/./contrib/openssl/ssl/statem/statem_clnt.c:1159:16 (clickhouse+0x202272ee) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#18 read_state_machine build_docker/./contrib/openssl/ssl/statem/statem.c:712:35 (clickhouse+0x2021e96d) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#19 state_machine build_docker/./contrib/openssl/ssl/statem/statem.c:478:21 (clickhouse+0x2021e96d)
    openssl#20 ossl_statem_connect build_docker/./contrib/openssl/ssl/statem/statem.c:297:12 (clickhouse+0x2021ddce) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#21 SSL_do_handshake build_docker/./contrib/openssl/ssl/ssl_lib.c:4746:19 (clickhouse+0x201a5781) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#22 SSL_connect build_docker/./contrib/openssl/ssl/ssl_lib.c:2208:12 (clickhouse+0x201a5893) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#23 Poco::Net::SecureSocketImpl::connectSSL(bool) build_docker/./base/poco/NetSSL_OpenSSL/src/SecureSocketImpl.cpp:206:11 (clickhouse+0x1d179567) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
```

```
  Previous read of size 4 at 0x7b08003d6810 by thread T553 (mutexes: write M4, write M5, write M6):
    #0 OPENSSL_sk_is_sorted build_docker/./contrib/openssl/crypto/stack/stack.c:490:33 (clickhouse+0x203adcff) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #1 get_cert_by_subject_ex build_docker/./contrib/openssl/crypto/x509/by_dir.c:423:10 (clickhouse+0x203b6d8f) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #2 X509_LOOKUP_by_subject_ex build_docker/./contrib/openssl/crypto/x509/x509_lu.c:105:16 (clickhouse+0x203d46ec) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #3 ossl_x509_store_ctx_get_by_subject build_docker/./contrib/openssl/crypto/x509/x509_lu.c:360:17 (clickhouse+0x203d46ec)
    #4 X509_STORE_CTX_get1_issuer build_docker/./contrib/openssl/crypto/x509/x509_lu.c:782:10 (clickhouse+0x203d56cb) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #5 get1_trusted_issuer build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:3194:10 (clickhouse+0x203db4a9) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #6 build_chain build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:3324:40 (clickhouse+0x203db4a9)
    #7 verify_chain build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:240:15 (clickhouse+0x203dbe27) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #8 x509_verify_x509 build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:358 (clickhouse+0x203d7fd8) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#9 X509_verify_cert build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:293:56 (clickhouse+0x203d8215) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#10 ssl_verify_internal build_docker/./contrib/openssl/ssl/ssl_cert.c:496:13 (clickhouse+0x2019a2a4) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#11 ssl_verify_cert_chain build_docker/./contrib/openssl/ssl/ssl_cert.c:543:12 (clickhouse+0x2019a402) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#12 tls_post_process_server_certificate build_docker/./contrib/openssl/ssl/statem/statem_clnt.c:2072:9 (clickhouse+0x20227658) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#13 ossl_statem_client_post_process_message build_docker/./contrib/openssl/ssl/statem/statem_clnt.c:1159:16 (clickhouse+0x202272ee) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#14 read_state_machine build_docker/./contrib/openssl/ssl/statem/statem.c:712:35 (clickhouse+0x2021e96d) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#15 state_machine build_docker/./contrib/openssl/ssl/statem/statem.c:478:21 (clickhouse+0x2021e96d)
    openssl#16 ossl_statem_connect build_docker/./contrib/openssl/ssl/statem/statem.c:297:12 (clickhouse+0x2021ddce) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#17 SSL_do_handshake build_docker/./contrib/openssl/ssl/ssl_lib.c:4746:19 (clickhouse+0x201a5781) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#18 SSL_connect build_docker/./contrib/openssl/ssl/ssl_lib.c:2208:12 (clickhouse+0x201a5893) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#19 Poco::Net::SecureSocketImpl::connectSSL(bool) build_docker/./base/poco/NetSSL_OpenSSL/src/SecureSocketImpl.cpp:206:11 (clickhouse+0x1d179567) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
```
rschu1ze added a commit to ClickHouse/openssl that referenced this pull request Apr 29, 2024
The following issue was found in automatic tests with thread sanitizer
builds in ClickHouse (which uses OpenSSL 3.2.1) [0].

The first stack [1] does proper locking (function 'x509_store_add',
x509_lu.c) but in the second stack [2], function 'get_cert_by_subject_ex'
(by_dir.b) forgets to lock when calling 'sk_X509_OBJECT_is_sorted'.

[0] ClickHouse/ClickHouse#63049

[1] WARNING: ThreadSanitizer: data race (pid=1870)
  Write of size 4 at 0x7b08003d6810 by thread T552 (mutexes: write M0, write M1, write M2, write M3):
    #0 OPENSSL_sk_insert build_docker/./contrib/openssl/crypto/stack/stack.c:280:16 (clickhouse+0x203ad7e4) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #1 OPENSSL_sk_push build_docker/./contrib/openssl/crypto/stack/stack.c:401:12 (clickhouse+0x203ad7e4)
    #2 x509_store_add build_docker/./contrib/openssl/crypto/x509/x509_lu.c:419:17 (clickhouse+0x203d4a52) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #3 X509_STORE_add_cert build_docker/./contrib/openssl/crypto/x509/x509_lu.c:432:10 (clickhouse+0x203d48a2) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #4 X509_load_cert_file_ex build_docker/./contrib/openssl/crypto/x509/by_file.c:127:18 (clickhouse+0x203b74e6) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #5 get_cert_by_subject_ex build_docker/./contrib/openssl/crypto/x509/by_dir.c:333:22 (clickhouse+0x203b684c) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #6 X509_LOOKUP_by_subject_ex build_docker/./contrib/openssl/crypto/x509/x509_lu.c:105:16 (clickhouse+0x203d46ec) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #7 ossl_x509_store_ctx_get_by_subject build_docker/./contrib/openssl/crypto/x509/x509_lu.c:360:17 (clickhouse+0x203d46ec)
    #8 X509_STORE_CTX_get1_issuer build_docker/./contrib/openssl/crypto/x509/x509_lu.c:782:10 (clickhouse+0x203d56cb) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#9 get1_trusted_issuer build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:3194:10 (clickhouse+0x203db4a9) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#10 build_chain build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:3324:40 (clickhouse+0x203db4a9)
    openssl#11 verify_chain build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:240:15 (clickhouse+0x203dbe27) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#12 x509_verify_x509 build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:358 (clickhouse+0x203d7fd8) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#13 X509_verify_cert build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:293:56 (clickhouse+0x203d8215) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#14 ssl_verify_internal build_docker/./contrib/openssl/ssl/ssl_cert.c:496:13 (clickhouse+0x2019a2a4) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#15 ssl_verify_cert_chain build_docker/./contrib/openssl/ssl/ssl_cert.c:543:12 (clickhouse+0x2019a402) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#16 tls_post_process_server_certificate build_docker/./contrib/openssl/ssl/statem/statem_clnt.c:2072:9 (clickhouse+0x20227658) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#17 ossl_statem_client_post_process_message build_docker/./contrib/openssl/ssl/statem/statem_clnt.c:1159:16 (clickhouse+0x202272ee) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#18 read_state_machine build_docker/./contrib/openssl/ssl/statem/statem.c:712:35 (clickhouse+0x2021e96d) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#19 state_machine build_docker/./contrib/openssl/ssl/statem/statem.c:478:21 (clickhouse+0x2021e96d)
    openssl#20 ossl_statem_connect build_docker/./contrib/openssl/ssl/statem/statem.c:297:12 (clickhouse+0x2021ddce) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#21 SSL_do_handshake build_docker/./contrib/openssl/ssl/ssl_lib.c:4746:19 (clickhouse+0x201a5781) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#22 SSL_connect build_docker/./contrib/openssl/ssl/ssl_lib.c:2208:12 (clickhouse+0x201a5893) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#23 Poco::Net::SecureSocketImpl::connectSSL(bool) build_docker/./base/poco/NetSSL_OpenSSL/src/SecureSocketImpl.cpp:206:11 (clickhouse+0x1d179567) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)

[2] Previous read of size 4 at 0x7b08003d6810 by thread T553 (mutexes: write M4, write M5, write M6):
    #0 OPENSSL_sk_is_sorted build_docker/./contrib/openssl/crypto/stack/stack.c:490:33 (clickhouse+0x203adcff) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #1 get_cert_by_subject_ex build_docker/./contrib/openssl/crypto/x509/by_dir.c:423:10 (clickhouse+0x203b6d8f) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #2 X509_LOOKUP_by_subject_ex build_docker/./contrib/openssl/crypto/x509/x509_lu.c:105:16 (clickhouse+0x203d46ec) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #3 ossl_x509_store_ctx_get_by_subject build_docker/./contrib/openssl/crypto/x509/x509_lu.c:360:17 (clickhouse+0x203d46ec)
    #4 X509_STORE_CTX_get1_issuer build_docker/./contrib/openssl/crypto/x509/x509_lu.c:782:10 (clickhouse+0x203d56cb) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #5 get1_trusted_issuer build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:3194:10 (clickhouse+0x203db4a9) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #6 build_chain build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:3324:40 (clickhouse+0x203db4a9)
    #7 verify_chain build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:240:15 (clickhouse+0x203dbe27) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #8 x509_verify_x509 build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:358 (clickhouse+0x203d7fd8) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#9 X509_verify_cert build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:293:56 (clickhouse+0x203d8215) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#10 ssl_verify_internal build_docker/./contrib/openssl/ssl/ssl_cert.c:496:13 (clickhouse+0x2019a2a4) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#11 ssl_verify_cert_chain build_docker/./contrib/openssl/ssl/ssl_cert.c:543:12 (clickhouse+0x2019a402) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#12 tls_post_process_server_certificate build_docker/./contrib/openssl/ssl/statem/statem_clnt.c:2072:9 (clickhouse+0x20227658) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#13 ossl_statem_client_post_process_message build_docker/./contrib/openssl/ssl/statem/statem_clnt.c:1159:16 (clickhouse+0x202272ee) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#14 read_state_machine build_docker/./contrib/openssl/ssl/statem/statem.c:712:35 (clickhouse+0x2021e96d) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#15 state_machine build_docker/./contrib/openssl/ssl/statem/statem.c:478:21 (clickhouse+0x2021e96d)
    openssl#16 ossl_statem_connect build_docker/./contrib/openssl/ssl/statem/statem.c:297:12 (clickhouse+0x2021ddce) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#17 SSL_do_handshake build_docker/./contrib/openssl/ssl/ssl_lib.c:4746:19 (clickhouse+0x201a5781) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#18 SSL_connect build_docker/./contrib/openssl/ssl/ssl_lib.c:2208:12 (clickhouse+0x201a5893) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    openssl#19 Poco::Net::SecureSocketImpl::connectSSL(bool) build_docker/./base/poco/NetSSL_OpenSSL/src/SecureSocketImpl.cpp:206:11 (clickhouse+0x1d179567) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)

CLA: trivial
openssl-machine pushed a commit that referenced this pull request Apr 30, 2024
The following issue was found in automatic tests with thread sanitizer
builds in ClickHouse (which uses OpenSSL 3.2.1) [0].

The first stack [1] does proper locking (function 'x509_store_add',
x509_lu.c) but in the second stack [2], function 'get_cert_by_subject_ex'
(by_dir.b) forgets to lock when calling 'sk_X509_OBJECT_is_sorted'.

[0] ClickHouse/ClickHouse#63049

[1] WARNING: ThreadSanitizer: data race (pid=1870)
  Write of size 4 at 0x7b08003d6810 by thread T552 (mutexes: write M0, write M1, write M2, write M3):
    #0 OPENSSL_sk_insert build_docker/./contrib/openssl/crypto/stack/stack.c:280:16 (clickhouse+0x203ad7e4) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #1 OPENSSL_sk_push build_docker/./contrib/openssl/crypto/stack/stack.c:401:12 (clickhouse+0x203ad7e4)
    #2 x509_store_add build_docker/./contrib/openssl/crypto/x509/x509_lu.c:419:17 (clickhouse+0x203d4a52) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #3 X509_STORE_add_cert build_docker/./contrib/openssl/crypto/x509/x509_lu.c:432:10 (clickhouse+0x203d48a2) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #4 X509_load_cert_file_ex build_docker/./contrib/openssl/crypto/x509/by_file.c:127:18 (clickhouse+0x203b74e6) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #5 get_cert_by_subject_ex build_docker/./contrib/openssl/crypto/x509/by_dir.c:333:22 (clickhouse+0x203b684c) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #6 X509_LOOKUP_by_subject_ex build_docker/./contrib/openssl/crypto/x509/x509_lu.c:105:16 (clickhouse+0x203d46ec) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #7 ossl_x509_store_ctx_get_by_subject build_docker/./contrib/openssl/crypto/x509/x509_lu.c:360:17 (clickhouse+0x203d46ec)
    #8 X509_STORE_CTX_get1_issuer build_docker/./contrib/openssl/crypto/x509/x509_lu.c:782:10 (clickhouse+0x203d56cb) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #9 get1_trusted_issuer build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:3194:10 (clickhouse+0x203db4a9) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #10 build_chain build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:3324:40 (clickhouse+0x203db4a9)
    #11 verify_chain build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:240:15 (clickhouse+0x203dbe27) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #12 x509_verify_x509 build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:358 (clickhouse+0x203d7fd8) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #13 X509_verify_cert build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:293:56 (clickhouse+0x203d8215) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #14 ssl_verify_internal build_docker/./contrib/openssl/ssl/ssl_cert.c:496:13 (clickhouse+0x2019a2a4) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #15 ssl_verify_cert_chain build_docker/./contrib/openssl/ssl/ssl_cert.c:543:12 (clickhouse+0x2019a402) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #16 tls_post_process_server_certificate build_docker/./contrib/openssl/ssl/statem/statem_clnt.c:2072:9 (clickhouse+0x20227658) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #17 ossl_statem_client_post_process_message build_docker/./contrib/openssl/ssl/statem/statem_clnt.c:1159:16 (clickhouse+0x202272ee) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #18 read_state_machine build_docker/./contrib/openssl/ssl/statem/statem.c:712:35 (clickhouse+0x2021e96d) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #19 state_machine build_docker/./contrib/openssl/ssl/statem/statem.c:478:21 (clickhouse+0x2021e96d)
    #20 ossl_statem_connect build_docker/./contrib/openssl/ssl/statem/statem.c:297:12 (clickhouse+0x2021ddce) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #21 SSL_do_handshake build_docker/./contrib/openssl/ssl/ssl_lib.c:4746:19 (clickhouse+0x201a5781) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #22 SSL_connect build_docker/./contrib/openssl/ssl/ssl_lib.c:2208:12 (clickhouse+0x201a5893) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #23 Poco::Net::SecureSocketImpl::connectSSL(bool) build_docker/./base/poco/NetSSL_OpenSSL/src/SecureSocketImpl.cpp:206:11 (clickhouse+0x1d179567) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)

[2] Previous read of size 4 at 0x7b08003d6810 by thread T553 (mutexes: write M4, write M5, write M6):
    #0 OPENSSL_sk_is_sorted build_docker/./contrib/openssl/crypto/stack/stack.c:490:33 (clickhouse+0x203adcff) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #1 get_cert_by_subject_ex build_docker/./contrib/openssl/crypto/x509/by_dir.c:423:10 (clickhouse+0x203b6d8f) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #2 X509_LOOKUP_by_subject_ex build_docker/./contrib/openssl/crypto/x509/x509_lu.c:105:16 (clickhouse+0x203d46ec) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #3 ossl_x509_store_ctx_get_by_subject build_docker/./contrib/openssl/crypto/x509/x509_lu.c:360:17 (clickhouse+0x203d46ec)
    #4 X509_STORE_CTX_get1_issuer build_docker/./contrib/openssl/crypto/x509/x509_lu.c:782:10 (clickhouse+0x203d56cb) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #5 get1_trusted_issuer build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:3194:10 (clickhouse+0x203db4a9) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #6 build_chain build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:3324:40 (clickhouse+0x203db4a9)
    #7 verify_chain build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:240:15 (clickhouse+0x203dbe27) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #8 x509_verify_x509 build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:358 (clickhouse+0x203d7fd8) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #9 X509_verify_cert build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:293:56 (clickhouse+0x203d8215) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #10 ssl_verify_internal build_docker/./contrib/openssl/ssl/ssl_cert.c:496:13 (clickhouse+0x2019a2a4) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #11 ssl_verify_cert_chain build_docker/./contrib/openssl/ssl/ssl_cert.c:543:12 (clickhouse+0x2019a402) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #12 tls_post_process_server_certificate build_docker/./contrib/openssl/ssl/statem/statem_clnt.c:2072:9 (clickhouse+0x20227658) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #13 ossl_statem_client_post_process_message build_docker/./contrib/openssl/ssl/statem/statem_clnt.c:1159:16 (clickhouse+0x202272ee) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #14 read_state_machine build_docker/./contrib/openssl/ssl/statem/statem.c:712:35 (clickhouse+0x2021e96d) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #15 state_machine build_docker/./contrib/openssl/ssl/statem/statem.c:478:21 (clickhouse+0x2021e96d)
    #16 ossl_statem_connect build_docker/./contrib/openssl/ssl/statem/statem.c:297:12 (clickhouse+0x2021ddce) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #17 SSL_do_handshake build_docker/./contrib/openssl/ssl/ssl_lib.c:4746:19 (clickhouse+0x201a5781) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #18 SSL_connect build_docker/./contrib/openssl/ssl/ssl_lib.c:2208:12 (clickhouse+0x201a5893) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #19 Poco::Net::SecureSocketImpl::connectSSL(bool) build_docker/./base/poco/NetSSL_OpenSSL/src/SecureSocketImpl.cpp:206:11 (clickhouse+0x1d179567) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)

CLA: trivial

Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #24295)

(cherry picked from commit af75373)
openssl-machine pushed a commit that referenced this pull request Apr 30, 2024
The following issue was found in automatic tests with thread sanitizer
builds in ClickHouse (which uses OpenSSL 3.2.1) [0].

The first stack [1] does proper locking (function 'x509_store_add',
x509_lu.c) but in the second stack [2], function 'get_cert_by_subject_ex'
(by_dir.b) forgets to lock when calling 'sk_X509_OBJECT_is_sorted'.

[0] ClickHouse/ClickHouse#63049

[1] WARNING: ThreadSanitizer: data race (pid=1870)
  Write of size 4 at 0x7b08003d6810 by thread T552 (mutexes: write M0, write M1, write M2, write M3):
    #0 OPENSSL_sk_insert build_docker/./contrib/openssl/crypto/stack/stack.c:280:16 (clickhouse+0x203ad7e4) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #1 OPENSSL_sk_push build_docker/./contrib/openssl/crypto/stack/stack.c:401:12 (clickhouse+0x203ad7e4)
    #2 x509_store_add build_docker/./contrib/openssl/crypto/x509/x509_lu.c:419:17 (clickhouse+0x203d4a52) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #3 X509_STORE_add_cert build_docker/./contrib/openssl/crypto/x509/x509_lu.c:432:10 (clickhouse+0x203d48a2) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #4 X509_load_cert_file_ex build_docker/./contrib/openssl/crypto/x509/by_file.c:127:18 (clickhouse+0x203b74e6) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #5 get_cert_by_subject_ex build_docker/./contrib/openssl/crypto/x509/by_dir.c:333:22 (clickhouse+0x203b684c) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #6 X509_LOOKUP_by_subject_ex build_docker/./contrib/openssl/crypto/x509/x509_lu.c:105:16 (clickhouse+0x203d46ec) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #7 ossl_x509_store_ctx_get_by_subject build_docker/./contrib/openssl/crypto/x509/x509_lu.c:360:17 (clickhouse+0x203d46ec)
    #8 X509_STORE_CTX_get1_issuer build_docker/./contrib/openssl/crypto/x509/x509_lu.c:782:10 (clickhouse+0x203d56cb) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #9 get1_trusted_issuer build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:3194:10 (clickhouse+0x203db4a9) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #10 build_chain build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:3324:40 (clickhouse+0x203db4a9)
    #11 verify_chain build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:240:15 (clickhouse+0x203dbe27) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #12 x509_verify_x509 build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:358 (clickhouse+0x203d7fd8) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #13 X509_verify_cert build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:293:56 (clickhouse+0x203d8215) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #14 ssl_verify_internal build_docker/./contrib/openssl/ssl/ssl_cert.c:496:13 (clickhouse+0x2019a2a4) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #15 ssl_verify_cert_chain build_docker/./contrib/openssl/ssl/ssl_cert.c:543:12 (clickhouse+0x2019a402) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #16 tls_post_process_server_certificate build_docker/./contrib/openssl/ssl/statem/statem_clnt.c:2072:9 (clickhouse+0x20227658) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #17 ossl_statem_client_post_process_message build_docker/./contrib/openssl/ssl/statem/statem_clnt.c:1159:16 (clickhouse+0x202272ee) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #18 read_state_machine build_docker/./contrib/openssl/ssl/statem/statem.c:712:35 (clickhouse+0x2021e96d) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #19 state_machine build_docker/./contrib/openssl/ssl/statem/statem.c:478:21 (clickhouse+0x2021e96d)
    #20 ossl_statem_connect build_docker/./contrib/openssl/ssl/statem/statem.c:297:12 (clickhouse+0x2021ddce) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #21 SSL_do_handshake build_docker/./contrib/openssl/ssl/ssl_lib.c:4746:19 (clickhouse+0x201a5781) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #22 SSL_connect build_docker/./contrib/openssl/ssl/ssl_lib.c:2208:12 (clickhouse+0x201a5893) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #23 Poco::Net::SecureSocketImpl::connectSSL(bool) build_docker/./base/poco/NetSSL_OpenSSL/src/SecureSocketImpl.cpp:206:11 (clickhouse+0x1d179567) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)

[2] Previous read of size 4 at 0x7b08003d6810 by thread T553 (mutexes: write M4, write M5, write M6):
    #0 OPENSSL_sk_is_sorted build_docker/./contrib/openssl/crypto/stack/stack.c:490:33 (clickhouse+0x203adcff) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #1 get_cert_by_subject_ex build_docker/./contrib/openssl/crypto/x509/by_dir.c:423:10 (clickhouse+0x203b6d8f) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #2 X509_LOOKUP_by_subject_ex build_docker/./contrib/openssl/crypto/x509/x509_lu.c:105:16 (clickhouse+0x203d46ec) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #3 ossl_x509_store_ctx_get_by_subject build_docker/./contrib/openssl/crypto/x509/x509_lu.c:360:17 (clickhouse+0x203d46ec)
    #4 X509_STORE_CTX_get1_issuer build_docker/./contrib/openssl/crypto/x509/x509_lu.c:782:10 (clickhouse+0x203d56cb) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #5 get1_trusted_issuer build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:3194:10 (clickhouse+0x203db4a9) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #6 build_chain build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:3324:40 (clickhouse+0x203db4a9)
    #7 verify_chain build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:240:15 (clickhouse+0x203dbe27) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #8 x509_verify_x509 build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:358 (clickhouse+0x203d7fd8) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #9 X509_verify_cert build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:293:56 (clickhouse+0x203d8215) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #10 ssl_verify_internal build_docker/./contrib/openssl/ssl/ssl_cert.c:496:13 (clickhouse+0x2019a2a4) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #11 ssl_verify_cert_chain build_docker/./contrib/openssl/ssl/ssl_cert.c:543:12 (clickhouse+0x2019a402) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #12 tls_post_process_server_certificate build_docker/./contrib/openssl/ssl/statem/statem_clnt.c:2072:9 (clickhouse+0x20227658) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #13 ossl_statem_client_post_process_message build_docker/./contrib/openssl/ssl/statem/statem_clnt.c:1159:16 (clickhouse+0x202272ee) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #14 read_state_machine build_docker/./contrib/openssl/ssl/statem/statem.c:712:35 (clickhouse+0x2021e96d) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #15 state_machine build_docker/./contrib/openssl/ssl/statem/statem.c:478:21 (clickhouse+0x2021e96d)
    #16 ossl_statem_connect build_docker/./contrib/openssl/ssl/statem/statem.c:297:12 (clickhouse+0x2021ddce) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #17 SSL_do_handshake build_docker/./contrib/openssl/ssl/ssl_lib.c:4746:19 (clickhouse+0x201a5781) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #18 SSL_connect build_docker/./contrib/openssl/ssl/ssl_lib.c:2208:12 (clickhouse+0x201a5893) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #19 Poco::Net::SecureSocketImpl::connectSSL(bool) build_docker/./base/poco/NetSSL_OpenSSL/src/SecureSocketImpl.cpp:206:11 (clickhouse+0x1d179567) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)

CLA: trivial

Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #24295)

(cherry picked from commit af75373)
openssl-machine pushed a commit that referenced this pull request Apr 30, 2024
The following issue was found in automatic tests with thread sanitizer
builds in ClickHouse (which uses OpenSSL 3.2.1) [0].

The first stack [1] does proper locking (function 'x509_store_add',
x509_lu.c) but in the second stack [2], function 'get_cert_by_subject_ex'
(by_dir.b) forgets to lock when calling 'sk_X509_OBJECT_is_sorted'.

[0] ClickHouse/ClickHouse#63049

[1] WARNING: ThreadSanitizer: data race (pid=1870)
  Write of size 4 at 0x7b08003d6810 by thread T552 (mutexes: write M0, write M1, write M2, write M3):
    #0 OPENSSL_sk_insert build_docker/./contrib/openssl/crypto/stack/stack.c:280:16 (clickhouse+0x203ad7e4) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #1 OPENSSL_sk_push build_docker/./contrib/openssl/crypto/stack/stack.c:401:12 (clickhouse+0x203ad7e4)
    #2 x509_store_add build_docker/./contrib/openssl/crypto/x509/x509_lu.c:419:17 (clickhouse+0x203d4a52) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #3 X509_STORE_add_cert build_docker/./contrib/openssl/crypto/x509/x509_lu.c:432:10 (clickhouse+0x203d48a2) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #4 X509_load_cert_file_ex build_docker/./contrib/openssl/crypto/x509/by_file.c:127:18 (clickhouse+0x203b74e6) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #5 get_cert_by_subject_ex build_docker/./contrib/openssl/crypto/x509/by_dir.c:333:22 (clickhouse+0x203b684c) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #6 X509_LOOKUP_by_subject_ex build_docker/./contrib/openssl/crypto/x509/x509_lu.c:105:16 (clickhouse+0x203d46ec) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #7 ossl_x509_store_ctx_get_by_subject build_docker/./contrib/openssl/crypto/x509/x509_lu.c:360:17 (clickhouse+0x203d46ec)
    #8 X509_STORE_CTX_get1_issuer build_docker/./contrib/openssl/crypto/x509/x509_lu.c:782:10 (clickhouse+0x203d56cb) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #9 get1_trusted_issuer build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:3194:10 (clickhouse+0x203db4a9) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #10 build_chain build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:3324:40 (clickhouse+0x203db4a9)
    #11 verify_chain build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:240:15 (clickhouse+0x203dbe27) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #12 x509_verify_x509 build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:358 (clickhouse+0x203d7fd8) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #13 X509_verify_cert build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:293:56 (clickhouse+0x203d8215) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #14 ssl_verify_internal build_docker/./contrib/openssl/ssl/ssl_cert.c:496:13 (clickhouse+0x2019a2a4) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #15 ssl_verify_cert_chain build_docker/./contrib/openssl/ssl/ssl_cert.c:543:12 (clickhouse+0x2019a402) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #16 tls_post_process_server_certificate build_docker/./contrib/openssl/ssl/statem/statem_clnt.c:2072:9 (clickhouse+0x20227658) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #17 ossl_statem_client_post_process_message build_docker/./contrib/openssl/ssl/statem/statem_clnt.c:1159:16 (clickhouse+0x202272ee) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #18 read_state_machine build_docker/./contrib/openssl/ssl/statem/statem.c:712:35 (clickhouse+0x2021e96d) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #19 state_machine build_docker/./contrib/openssl/ssl/statem/statem.c:478:21 (clickhouse+0x2021e96d)
    #20 ossl_statem_connect build_docker/./contrib/openssl/ssl/statem/statem.c:297:12 (clickhouse+0x2021ddce) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #21 SSL_do_handshake build_docker/./contrib/openssl/ssl/ssl_lib.c:4746:19 (clickhouse+0x201a5781) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #22 SSL_connect build_docker/./contrib/openssl/ssl/ssl_lib.c:2208:12 (clickhouse+0x201a5893) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #23 Poco::Net::SecureSocketImpl::connectSSL(bool) build_docker/./base/poco/NetSSL_OpenSSL/src/SecureSocketImpl.cpp:206:11 (clickhouse+0x1d179567) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)

[2] Previous read of size 4 at 0x7b08003d6810 by thread T553 (mutexes: write M4, write M5, write M6):
    #0 OPENSSL_sk_is_sorted build_docker/./contrib/openssl/crypto/stack/stack.c:490:33 (clickhouse+0x203adcff) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #1 get_cert_by_subject_ex build_docker/./contrib/openssl/crypto/x509/by_dir.c:423:10 (clickhouse+0x203b6d8f) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #2 X509_LOOKUP_by_subject_ex build_docker/./contrib/openssl/crypto/x509/x509_lu.c:105:16 (clickhouse+0x203d46ec) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #3 ossl_x509_store_ctx_get_by_subject build_docker/./contrib/openssl/crypto/x509/x509_lu.c:360:17 (clickhouse+0x203d46ec)
    #4 X509_STORE_CTX_get1_issuer build_docker/./contrib/openssl/crypto/x509/x509_lu.c:782:10 (clickhouse+0x203d56cb) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #5 get1_trusted_issuer build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:3194:10 (clickhouse+0x203db4a9) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #6 build_chain build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:3324:40 (clickhouse+0x203db4a9)
    #7 verify_chain build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:240:15 (clickhouse+0x203dbe27) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #8 x509_verify_x509 build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:358 (clickhouse+0x203d7fd8) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #9 X509_verify_cert build_docker/./contrib/openssl/crypto/x509/x509_vfy.c:293:56 (clickhouse+0x203d8215) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #10 ssl_verify_internal build_docker/./contrib/openssl/ssl/ssl_cert.c:496:13 (clickhouse+0x2019a2a4) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #11 ssl_verify_cert_chain build_docker/./contrib/openssl/ssl/ssl_cert.c:543:12 (clickhouse+0x2019a402) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #12 tls_post_process_server_certificate build_docker/./contrib/openssl/ssl/statem/statem_clnt.c:2072:9 (clickhouse+0x20227658) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #13 ossl_statem_client_post_process_message build_docker/./contrib/openssl/ssl/statem/statem_clnt.c:1159:16 (clickhouse+0x202272ee) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #14 read_state_machine build_docker/./contrib/openssl/ssl/statem/statem.c:712:35 (clickhouse+0x2021e96d) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #15 state_machine build_docker/./contrib/openssl/ssl/statem/statem.c:478:21 (clickhouse+0x2021e96d)
    #16 ossl_statem_connect build_docker/./contrib/openssl/ssl/statem/statem.c:297:12 (clickhouse+0x2021ddce) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #17 SSL_do_handshake build_docker/./contrib/openssl/ssl/ssl_lib.c:4746:19 (clickhouse+0x201a5781) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #18 SSL_connect build_docker/./contrib/openssl/ssl/ssl_lib.c:2208:12 (clickhouse+0x201a5893) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)
    #19 Poco::Net::SecureSocketImpl::connectSSL(bool) build_docker/./base/poco/NetSSL_OpenSSL/src/SecureSocketImpl.cpp:206:11 (clickhouse+0x1d179567) (BuildId: 3ceefd39df36d762f06bf9aab19cfc3467e4558b)

CLA: trivial

Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #24295)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants