Commit c2bccf040e for openssl.org

commit c2bccf040e772a4b4db52489f99839f7c4e01426
Author: Bob Beck <beck@openssl.org>
Date:   Wed Aug 5 14:29:19 2026 -0600

    Don't hit the legacy strlen case in ASN1_STRING_copy

    This should avoid the warning for calling strlen() on data in gcc

    Reviewed-by: Neil Horman <nhorman@openssl.org>
    Reviewed-by: Andrew Dinh <andrewd@openssl.org>
    Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
    Merge-date: Thu Aug 27 13:52:47 2026
    Merged-from: https://github.com/openssl/openssl/pull/32178

diff --git a/crypto/asn1/asn1_lib.c b/crypto/asn1/asn1_lib.c
index 7209e470b3..a73c677ffe 100644
--- a/crypto/asn1/asn1_lib.c
+++ b/crypto/asn1/asn1_lib.c
@@ -262,7 +262,7 @@ void ossl_asn1_bit_string_set_unused_bits(ASN1_STRING *str, unsigned int num)

 int ASN1_STRING_copy(ASN1_STRING *dst, const ASN1_STRING *str)
 {
-    if (str == NULL)
+    if (str == NULL || str->length < 0)
         return 0;
     dst->type = str->type;
     if (!ossl_asn1_string_set_internal(dst, str->data, str->length,