Fix bug in strncpy() use of sk_ASN1_UTF8STRING2text() in asn1_lib.c
authorDr. David von Oheimb <David.von.Oheimb@siemens.com>
Fri, 20 Mar 2020 14:15:34 +0000 (15:15 +0100)
committerDr. David von Oheimb <David.von.Oheimb@siemens.com>
Wed, 25 Mar 2020 13:10:18 +0000 (14:10 +0100)
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/11300)

crypto/asn1/asn1_lib.c

index 765bbda5c74882b4d6c3ed20904e08e8b4d54323..fc4462eb8fe2a6ba053b85225cd5cd98cca05a17 100644 (file)
@@ -426,7 +426,7 @@ char *sk_ASN1_UTF8STRING2text(STACK_OF(ASN1_UTF8STRING) *text, const char *sep,
         current = sk_ASN1_UTF8STRING_value(text, i);
         length = ASN1_STRING_length(current);
         if (i > 0 && sep_len > 0) {
-            strncpy(p, sep, sep_len);
+            strncpy(p, sep, sep_len + 1);
             p += sep_len;
         }
         strncpy(p, (const char *)ASN1_STRING_get0_data(current), length);