diff options
author | jsing <> | 2018-03-20 16:16:59 +0000 |
---|---|---|
committer | jsing <> | 2018-03-20 16:16:59 +0000 |
commit | dd6b457d826067c635fb94da6b2872498fab0aca (patch) | |
tree | a0f774773971259eef778628e6f35d8b72ae806f /src | |
parent | d1fda77bd445ef89b9ec8f3a1b1f3cf04f68675b (diff) | |
download | openbsd-dd6b457d826067c635fb94da6b2872498fab0aca.tar.gz openbsd-dd6b457d826067c635fb94da6b2872498fab0aca.tar.bz2 openbsd-dd6b457d826067c635fb94da6b2872498fab0aca.zip |
If X509_check_{host,email}() are called with a length of zero, use strlen()
to determine the length. This is the documented behaviour and matches the
OpenSSL implementation.
Issue found by Michael Gmelin <freebsd at grem dot de>.
ok tb@
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/x509v3/v3_utl.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/lib/libcrypto/x509v3/v3_utl.c b/src/lib/libcrypto/x509v3/v3_utl.c index 04c789922b..67ecc81a44 100644 --- a/src/lib/libcrypto/x509v3/v3_utl.c +++ b/src/lib/libcrypto/x509v3/v3_utl.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: v3_utl.c,v 1.26 2017/01/29 17:49:23 beck Exp $ */ | 1 | /* $OpenBSD: v3_utl.c,v 1.27 2018/03/20 16:16:59 jsing 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 | */ |
@@ -1015,7 +1015,9 @@ int X509_check_host(X509 *x, const char *chk, size_t chklen, | |||
1015 | { | 1015 | { |
1016 | if (chk == NULL) | 1016 | if (chk == NULL) |
1017 | return -2; | 1017 | return -2; |
1018 | if (memchr(chk, '\0', chklen)) | 1018 | if (chklen == 0) |
1019 | chklen = strlen(chk); | ||
1020 | else if (memchr(chk, '\0', chklen)) | ||
1019 | return -2; | 1021 | return -2; |
1020 | return do_x509_check(x, chk, chklen, flags, GEN_DNS, peername); | 1022 | return do_x509_check(x, chk, chklen, flags, GEN_DNS, peername); |
1021 | } | 1023 | } |
@@ -1025,7 +1027,9 @@ int X509_check_email(X509 *x, const char *chk, size_t chklen, | |||
1025 | { | 1027 | { |
1026 | if (chk == NULL) | 1028 | if (chk == NULL) |
1027 | return -2; | 1029 | return -2; |
1028 | if (memchr(chk, '\0', chklen)) | 1030 | if (chklen == 0) |
1031 | chklen = strlen(chk); | ||
1032 | else if (memchr(chk, '\0', chklen)) | ||
1029 | return -2; | 1033 | return -2; |
1030 | return do_x509_check(x, chk, chklen, flags, GEN_EMAIL, NULL); | 1034 | return do_x509_check(x, chk, chklen, flags, GEN_EMAIL, NULL); |
1031 | } | 1035 | } |