Commit 3e601cafa4 for openssl.org
commit 3e601cafa4ddcfaac7224afbe43aa32414fb9e85
Author: Eugene Syromiatnikov <esyr@openssl.org>
Date: Tue Sep 22 16:48:52 2026 +0200
crypto/asn1/asn1_lib.c: append NUL byte in ASN1_STRING_copy()
This effectively reverts the behavioural change to ASN1_STRING_copy()
implemented in 28179061bfcd "Prepare a now opaque ASN1_STRING
for the size_t rapture." and complements cc55a5d82906 "NUL-terminate
ASN1_STRING data built inside libcrypto"
Complements: cc55a5d82906 "NUL-terminate ASN1_STRING data built inside libcrypto"
Signed-off-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Milan Broz <mbroz@openssl.org>
Reviewed-by: Bob Beck <beck@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
Merge-date: Tue Sep 29 16:23:23 2026
Merged-from: https://github.com/openssl/openssl/pull/32932
diff --git a/crypto/asn1/asn1_lib.c b/crypto/asn1/asn1_lib.c
index 825886ecbf..a216525f8d 100644
--- a/crypto/asn1/asn1_lib.c
+++ b/crypto/asn1/asn1_lib.c
@@ -292,7 +292,7 @@ int ASN1_STRING_copy(ASN1_STRING *dst, const ASN1_STRING *str)
return 0;
dst->type = str->type;
if (!ossl_asn1_string_set_internal(dst, str->data, str->length,
- /*add_nul_byte=*/0))
+ /*add_nul_byte=*/1))
return 0;
/* Copy flags but preserve embed value */
dst->flags &= ASN1_STRING_FLAG_EMBED;