diff options
author | tb <> | 2020-05-24 15:13:22 +0000 |
---|---|---|
committer | tb <> | 2020-05-24 15:13:22 +0000 |
commit | 6b123c2514b62068e195a1c693bfc13d5b796a74 (patch) | |
tree | ea891a4c457e6d5d0f2d1b7697f04e935ecf1481 /src | |
parent | 2212d9a0f501cbdaf1b71d000f925fb3778b99fd (diff) | |
download | openbsd-6b123c2514b62068e195a1c693bfc13d5b796a74.tar.gz openbsd-6b123c2514b62068e195a1c693bfc13d5b796a74.tar.bz2 openbsd-6b123c2514b62068e195a1c693bfc13d5b796a74.zip |
Fix some stylistic nits from jsing.
ok jsing
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libssl/ssl_tlsext.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/lib/libssl/ssl_tlsext.c b/src/lib/libssl/ssl_tlsext.c index 2184e65a2c..e6e0e7a92d 100644 --- a/src/lib/libssl/ssl_tlsext.c +++ b/src/lib/libssl/ssl_tlsext.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_tlsext.c,v 1.72 2020/05/23 17:13:24 beck Exp $ */ | 1 | /* $OpenBSD: ssl_tlsext.c,v 1.73 2020/05/24 15:13:22 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2016, 2017, 2019 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2016, 2017, 2019 Joel Sing <jsing@openbsd.org> |
4 | * Copyright (c) 2017 Doug Hogan <doug@openbsd.org> | 4 | * Copyright (c) 2017 Doug Hogan <doug@openbsd.org> |
@@ -17,9 +17,10 @@ | |||
17 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 17 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <openssl/ocsp.h> | ||
21 | #include <ctype.h> | 20 | #include <ctype.h> |
22 | 21 | ||
22 | #include <openssl/ocsp.h> | ||
23 | |||
23 | #include "ssl_locl.h" | 24 | #include "ssl_locl.h" |
24 | 25 | ||
25 | #include "bytestring.h" | 26 | #include "bytestring.h" |
@@ -674,8 +675,8 @@ tlsext_sni_client_build(SSL *s, CBB *cbb) | |||
674 | } | 675 | } |
675 | 676 | ||
676 | /* | 677 | /* |
677 | * Does the CBS contain only of a hostname consisting of RFC 5890 | 678 | * Validate that the CBS contains only a hostname consisting of RFC 5890 |
678 | * compliant A-labels? (see RFC 6066 section 3). Not a complete check | 679 | * compliant A-labels (see RFC 6066 section 3). Not a complete check |
679 | * since we don't parse punycode to verify its validity but limits to | 680 | * since we don't parse punycode to verify its validity but limits to |
680 | * correct structure and character set. | 681 | * correct structure and character set. |
681 | */ | 682 | */ |
@@ -686,10 +687,11 @@ tlsext_sni_is_valid_hostname(CBS *cbs) | |||
686 | int component = 0; | 687 | int component = 0; |
687 | CBS hostname; | 688 | CBS hostname; |
688 | 689 | ||
689 | if (CBS_len(cbs) > TLSEXT_MAXLEN_host_name) | 690 | CBS_dup(cbs, &hostname); |
691 | |||
692 | if (CBS_len(&hostname) > TLSEXT_MAXLEN_host_name) | ||
690 | return 0; | 693 | return 0; |
691 | 694 | ||
692 | CBS_dup(cbs, &hostname); | ||
693 | while(CBS_len(&hostname) > 0) { | 695 | while(CBS_len(&hostname) > 0) { |
694 | prev = c; | 696 | prev = c; |
695 | if (!CBS_get_u8(&hostname, &c)) | 697 | if (!CBS_get_u8(&hostname, &c)) |
@@ -698,7 +700,7 @@ tlsext_sni_is_valid_hostname(CBS *cbs) | |||
698 | if (!isascii(c) || c == '\0') | 700 | if (!isascii(c) || c == '\0') |
699 | return 0; | 701 | return 0; |
700 | /* It must be alphanumeric, a '-', or a '.' */ | 702 | /* It must be alphanumeric, a '-', or a '.' */ |
701 | if (!(isalnum(c) || c == '-' || c == '.')) | 703 | if (!isalnum(c) && c != '-' && c != '.') |
702 | return 0; | 704 | return 0; |
703 | /* '-' and '.' must not start a component or be at the end. */ | 705 | /* '-' and '.' must not start a component or be at the end. */ |
704 | if (component == 0 || CBS_len(&hostname) == 0) { | 706 | if (component == 0 || CBS_len(&hostname) == 0) { |
@@ -717,6 +719,7 @@ tlsext_sni_is_valid_hostname(CBS *cbs) | |||
717 | if (++component > 63) | 719 | if (++component > 63) |
718 | return 0; | 720 | return 0; |
719 | } | 721 | } |
722 | |||
720 | return 1; | 723 | return 1; |
721 | } | 724 | } |
722 | 725 | ||
@@ -748,7 +751,7 @@ tlsext_sni_server_parse(SSL *s, CBS *cbs, int *alert) | |||
748 | * RFC 6066 section 3 specifies a host name must be at least 1 byte | 751 | * RFC 6066 section 3 specifies a host name must be at least 1 byte |
749 | * so 0 length is a decode error. | 752 | * so 0 length is a decode error. |
750 | */ | 753 | */ |
751 | if (CBS_len(&host_name) == 0) | 754 | if (CBS_len(&host_name) < 1) |
752 | goto err; | 755 | goto err; |
753 | 756 | ||
754 | if (!tlsext_sni_is_valid_hostname(&host_name)) { | 757 | if (!tlsext_sni_is_valid_hostname(&host_name)) { |