diff options
| author | tb <> | 2023-06-01 07:29:15 +0000 |
|---|---|---|
| committer | tb <> | 2023-06-01 07:29:15 +0000 |
| commit | db144b29c2c0d748705612fa7cb0ef4ecaa7667d (patch) | |
| tree | 204afc29a69c2bca10670d98ef7212652e852472 /src/lib/libtls/tls_verify.c | |
| parent | 15d3c912ab27ed23d29447224f0220efc5eb1044 (diff) | |
| download | openbsd-db144b29c2c0d748705612fa7cb0ef4ecaa7667d.tar.gz openbsd-db144b29c2c0d748705612fa7cb0ef4ecaa7667d.tar.bz2 openbsd-db144b29c2c0d748705612fa7cb0ef4ecaa7667d.zip | |
Check for X509_get_ext_d2i() failure
X509_get_ext_d2i() (or rather X509V3_get_d2i()) can return NULL for
various reasons. If it fails because the extension wasn't found, it
sets *crit = -1. In any other case, e.g., the cert is bad or we ran
out of memory in X509V3_EXT_d2i(), crit is set to something else, so
we should actually error.
ok jsing
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libtls/tls_verify.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/lib/libtls/tls_verify.c b/src/lib/libtls/tls_verify.c index a0c39b9dd4..c3127fa4fe 100644 --- a/src/lib/libtls/tls_verify.c +++ b/src/lib/libtls/tls_verify.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: tls_verify.c,v 1.26 2023/05/29 14:12:36 beck Exp $ */ | 1 | /* $OpenBSD: tls_verify.c,v 1.27 2023/06/01 07:29:15 tb Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2014 Jeremie Courreges-Anglas <jca@openbsd.org> | 3 | * Copyright (c) 2014 Jeremie Courreges-Anglas <jca@openbsd.org> |
| 4 | * | 4 | * |
| @@ -92,15 +92,21 @@ tls_check_subject_altname(struct tls *ctx, X509 *cert, const char *name, | |||
| 92 | union tls_addr addrbuf; | 92 | union tls_addr addrbuf; |
| 93 | int addrlen, type; | 93 | int addrlen, type; |
| 94 | int count, i; | 94 | int count, i; |
| 95 | int critical = 0; | ||
| 95 | int rv = 0; | 96 | int rv = 0; |
| 96 | 97 | ||
| 97 | *alt_match = 0; | 98 | *alt_match = 0; |
| 98 | *alt_exists = 0; | 99 | *alt_exists = 0; |
| 99 | 100 | ||
| 100 | altname_stack = X509_get_ext_d2i(cert, NID_subject_alt_name, | 101 | altname_stack = X509_get_ext_d2i(cert, NID_subject_alt_name, &critical, |
| 101 | NULL, NULL); | 102 | NULL); |
| 102 | if (altname_stack == NULL) | 103 | if (altname_stack == NULL) { |
| 104 | if (critical != -1) { | ||
| 105 | tls_set_errorx(ctx, "error decoding subjectAltName"); | ||
| 106 | return -1; | ||
| 107 | } | ||
| 103 | return 0; | 108 | return 0; |
| 109 | } | ||
| 104 | 110 | ||
| 105 | if (inet_pton(AF_INET, name, &addrbuf) == 1) { | 111 | if (inet_pton(AF_INET, name, &addrbuf) == 1) { |
| 106 | type = GEN_IPADD; | 112 | type = GEN_IPADD; |
