summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authortb <>2022-03-03 11:29:05 +0000
committertb <>2022-03-03 11:29:05 +0000
commit7ff9203d8a907d87807eb46a6e75aa17ef165030 (patch)
tree8c542ec54925f5eb5bfc996fcd733e9167c371da /src/lib
parent81288dca65923a6787ab147e5b30bfceec126418 (diff)
downloadopenbsd-7ff9203d8a907d87807eb46a6e75aa17ef165030.tar.gz
openbsd-7ff9203d8a907d87807eb46a6e75aa17ef165030.tar.bz2
openbsd-7ff9203d8a907d87807eb46a6e75aa17ef165030.zip
Pull a len == 0 check up before malloc(len) to avoid implementation
defined behavior. ok deraadt inoguchi
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/x509/x509_constraints.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/lib/libcrypto/x509/x509_constraints.c b/src/lib/libcrypto/x509/x509_constraints.c
index 5320583137..c7adaa4b36 100644
--- a/src/lib/libcrypto/x509/x509_constraints.c
+++ b/src/lib/libcrypto/x509/x509_constraints.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_constraints.c,v 1.20 2022/03/02 17:53:03 tb Exp $ */ 1/* $OpenBSD: x509_constraints.c,v 1.21 2022/03/03 11:29:05 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2020 Bob Beck <beck@openbsd.org> 3 * Copyright (c) 2020 Bob Beck <beck@openbsd.org>
4 * 4 *
@@ -747,15 +747,15 @@ x509_constraints_extract_names(struct x509_constraints_names *names,
747 vname->type = GEN_URI; 747 vname->type = GEN_URI;
748 break; 748 break;
749 case GEN_DIRNAME: 749 case GEN_DIRNAME:
750 if (len == 0) {
751 *error = X509_V_ERR_UNSUPPORTED_NAME_SYNTAX;
752 goto err;
753 }
750 if (bytes == NULL || ((vname->der = malloc(len)) == 754 if (bytes == NULL || ((vname->der = malloc(len)) ==
751 NULL)) { 755 NULL)) {
752 *error = X509_V_ERR_OUT_OF_MEM; 756 *error = X509_V_ERR_OUT_OF_MEM;
753 goto err; 757 goto err;
754 } 758 }
755 if (len == 0) {
756 *error = X509_V_ERR_UNSUPPORTED_NAME_SYNTAX;
757 goto err;
758 }
759 memcpy(vname->der, bytes, len); 759 memcpy(vname->der, bytes, len);
760 vname->der_len = len; 760 vname->der_len = len;
761 vname->type = GEN_DIRNAME; 761 vname->type = GEN_DIRNAME;