summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortb <>2022-11-28 07:22:15 +0000
committertb <>2022-11-28 07:22:15 +0000
commit1b77f019fce5ce3f0dc81905cc3905e1f4fc2ba3 (patch)
tree27982dc03cac15781d7370c22b32454ee86cc0e0
parent7d6ea40c9e0e0897e7765f0607c1ab1f57aa70e0 (diff)
downloadopenbsd-1b77f019fce5ce3f0dc81905cc3905e1f4fc2ba3.tar.gz
openbsd-1b77f019fce5ce3f0dc81905cc3905e1f4fc2ba3.tar.bz2
openbsd-1b77f019fce5ce3f0dc81905cc3905e1f4fc2ba3.zip
Fix NULL dereference in x509_constraints_uri_host()
When called from v2i, hostpart in x509_constraints_uri_host() is NULL, so add a NULL check before storing the strdup result in it. From Anton Borowka ok jsing miod
-rw-r--r--src/lib/libcrypto/x509/x509_constraints.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/lib/libcrypto/x509/x509_constraints.c b/src/lib/libcrypto/x509/x509_constraints.c
index e0560c1578..1b79383de0 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.29 2022/11/11 12:02:34 beck Exp $ */ 1/* $OpenBSD: x509_constraints.c,v 1.30 2022/11/28 07:22:15 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2020 Bob Beck <beck@openbsd.org> 3 * Copyright (c) 2020 Bob Beck <beck@openbsd.org>
4 * 4 *
@@ -530,7 +530,8 @@ x509_constraints_uri_host(uint8_t *uri, size_t len, char **hostpart)
530 * we indicate that we have a URI with an empty 530 * we indicate that we have a URI with an empty
531 * host part, and succeed. 531 * host part, and succeed.
532 */ 532 */
533 *hostpart = strdup(""); 533 if (hostpart != NULL)
534 *hostpart = strdup("");
534 return 1; 535 return 1;
535 } 536 }
536 for (i = authority - uri; i < len; i++) { 537 for (i = authority - uri; i < len; i++) {