summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/x509/x509_alt.c
diff options
context:
space:
mode:
authortb <>2022-03-26 16:34:21 +0000
committertb <>2022-03-26 16:34:21 +0000
commit62e5583bb1b862560432775b3c0765db00173fc6 (patch)
treeb479f5e5efe3b6b03f82d771d623f8ae686fc6d0 /src/lib/libcrypto/x509/x509_alt.c
parent2ce3af26514a8bfe23e0605aa5b31dc0ab865be1 (diff)
downloadopenbsd-62e5583bb1b862560432775b3c0765db00173fc6.tar.gz
openbsd-62e5583bb1b862560432775b3c0765db00173fc6.tar.bz2
openbsd-62e5583bb1b862560432775b3c0765db00173fc6.zip
name constraints: be more careful with NULs
An IA5STRING is a Pascal string that can have embedded NULs and is not NUL terminated (except that for legacy reasons it happens to be). Instead of taking the strlen(), use the already known ASN.1 length and use strndup() instead of strdup() to generate NUL terminated strings after some existing code has checked that there are no embedded NULs. In v2i_GENERAL_NAME_ex() use %.*s to print the bytes. This is not optimal and might be switched to using strvis() later. ok beck inoguchi jsing
Diffstat (limited to 'src/lib/libcrypto/x509/x509_alt.c')
-rw-r--r--src/lib/libcrypto/x509/x509_alt.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/lib/libcrypto/x509/x509_alt.c b/src/lib/libcrypto/x509/x509_alt.c
index 845ab1364f..8656df82b3 100644
--- a/src/lib/libcrypto/x509/x509_alt.c
+++ b/src/lib/libcrypto/x509/x509_alt.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_alt.c,v 1.11 2022/03/14 21:15:49 tb Exp $ */ 1/* $OpenBSD: x509_alt.c,v 1.12 2022/03/26 16:34:21 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project. 3 * project.
4 */ 4 */
@@ -673,21 +673,24 @@ v2i_GENERAL_NAME_ex(GENERAL_NAME *out, const X509V3_EXT_METHOD *method,
673 case GEN_DNS: 673 case GEN_DNS:
674 if (!x509_constraints_valid_sandns(bytes, len)) { 674 if (!x509_constraints_valid_sandns(bytes, len)) {
675 X509V3error(X509V3_R_BAD_OBJECT); 675 X509V3error(X509V3_R_BAD_OBJECT);
676 ERR_asprintf_error_data("name=%s value='%s'", name, bytes); 676 ERR_asprintf_error_data("name=%s value='%.*s'", name,
677 (int)len, bytes);
677 goto err; 678 goto err;
678 } 679 }
679 break; 680 break;
680 case GEN_URI: 681 case GEN_URI:
681 if (!x509_constraints_uri_host(bytes, len, NULL)) { 682 if (!x509_constraints_uri_host(bytes, len, NULL)) {
682 X509V3error(X509V3_R_BAD_OBJECT); 683 X509V3error(X509V3_R_BAD_OBJECT);
683 ERR_asprintf_error_data("name=%s value='%s'", name, bytes); 684 ERR_asprintf_error_data("name=%s value='%.*s'", name,
685 (int)len, bytes);
684 goto err; 686 goto err;
685 } 687 }
686 break; 688 break;
687 case GEN_EMAIL: 689 case GEN_EMAIL:
688 if (!x509_constraints_parse_mailbox(bytes, len, NULL)) { 690 if (!x509_constraints_parse_mailbox(bytes, len, NULL)) {
689 X509V3error(X509V3_R_BAD_OBJECT); 691 X509V3error(X509V3_R_BAD_OBJECT);
690 ERR_asprintf_error_data("name=%s value='%s'", name, bytes); 692 ERR_asprintf_error_data("name=%s value='%.*s'", name,
693 (int)len, bytes);
691 goto err; 694 goto err;
692 } 695 }
693 break; 696 break;