apps/pkcs12: Do not assume null termination of ASN1_UTF8STRING
authorTomas Mraz <tomas@openssl.org>
Tue, 31 Aug 2021 07:05:59 +0000 (09:05 +0200)
committerTomas Mraz <tomas@openssl.org>
Tue, 31 Aug 2021 10:20:12 +0000 (12:20 +0200)
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from https://github.com/openssl/openssl/pull/16433)

apps/pkcs12.c

index d745df84943b0ec25d02bae116c2e86952155a2e..dcb173f201f3c3c8fb237827a6c8739c57ff7676 100644 (file)
@@ -1142,7 +1142,8 @@ void print_attribute(BIO *out, const ASN1_TYPE *av)
         break;
 
     case V_ASN1_UTF8STRING:
-        BIO_printf(out, "%s\n", av->value.utf8string->data);
+        BIO_printf(out, "%.*s\n", av->value.utf8string->length,
+                   av->value.utf8string->data);
         break;
 
     case V_ASN1_OCTET_STRING: