summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2020-01-22 10:28:49 +0000
committertb <>2020-01-22 10:28:49 +0000
commitbd8add8e67126e3d5b120b2316d4dfc94eba57d0 (patch)
tree13cf5ca7ef9a776350738fdf58c740e3eea720f6 /src
parent5b77cdf79751ec0ec2e3f2b0a0d159d7f16d9e21 (diff)
downloadopenbsd-bd8add8e67126e3d5b120b2316d4dfc94eba57d0.tar.gz
openbsd-bd8add8e67126e3d5b120b2316d4dfc94eba57d0.tar.bz2
openbsd-bd8add8e67126e3d5b120b2316d4dfc94eba57d0.zip
Avoid modifying alert in the success path.
ok beck jsing
Diffstat (limited to 'src')
-rw-r--r--src/lib/libssl/ssl_tlsext.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/lib/libssl/ssl_tlsext.c b/src/lib/libssl/ssl_tlsext.c
index fdaf251be4..d45dd50863 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.51 2019/11/16 15:36:53 beck Exp $ */ 1/* $OpenBSD: ssl_tlsext.c,v 1.52 2020/01/22 10:28:49 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>
@@ -1936,6 +1936,7 @@ tlsext_parse(SSL *s, CBS *cbs, int *alert, int is_server, uint16_t msg_type)
1936 uint16_t type; 1936 uint16_t type;
1937 size_t idx; 1937 size_t idx;
1938 uint16_t version; 1938 uint16_t version;
1939 uint8_t alert_desc;
1939 1940
1940 S3I(s)->hs.extensions_seen = 0; 1941 S3I(s)->hs.extensions_seen = 0;
1941 1942
@@ -1948,16 +1949,16 @@ tlsext_parse(SSL *s, CBS *cbs, int *alert, int is_server, uint16_t msg_type)
1948 if (CBS_len(cbs) == 0) 1949 if (CBS_len(cbs) == 0)
1949 return 1; 1950 return 1;
1950 1951
1951 *alert = SSL_AD_DECODE_ERROR; 1952 alert_desc = SSL_AD_DECODE_ERROR;
1952 1953
1953 if (!CBS_get_u16_length_prefixed(cbs, &extensions)) 1954 if (!CBS_get_u16_length_prefixed(cbs, &extensions))
1954 return 0; 1955 goto err;
1955 1956
1956 while (CBS_len(&extensions) > 0) { 1957 while (CBS_len(&extensions) > 0) {
1957 if (!CBS_get_u16(&extensions, &type)) 1958 if (!CBS_get_u16(&extensions, &type))
1958 return 0; 1959 goto err;
1959 if (!CBS_get_u16_length_prefixed(&extensions, &extension_data)) 1960 if (!CBS_get_u16_length_prefixed(&extensions, &extension_data))
1960 return 0; 1961 goto err;
1961 1962
1962 if (s->internal->tlsext_debug_cb != NULL) 1963 if (s->internal->tlsext_debug_cb != NULL)
1963 s->internal->tlsext_debug_cb(s, is_server, type, 1964 s->internal->tlsext_debug_cb(s, is_server, type,
@@ -1972,24 +1973,29 @@ tlsext_parse(SSL *s, CBS *cbs, int *alert, int is_server, uint16_t msg_type)
1972 /* RFC 8446 Section 4.2 */ 1973 /* RFC 8446 Section 4.2 */
1973 if (version >= TLS1_3_VERSION && 1974 if (version >= TLS1_3_VERSION &&
1974 !(tlsext->messages & msg_type)) { 1975 !(tlsext->messages & msg_type)) {
1975 *alert = SSL_AD_ILLEGAL_PARAMETER; 1976 alert_desc = SSL_AD_ILLEGAL_PARAMETER;
1976 return 0; 1977 goto err;
1977 } 1978 }
1978 1979
1979 /* Check for duplicate known extensions. */ 1980 /* Check for duplicate known extensions. */
1980 if ((S3I(s)->hs.extensions_seen & (1 << idx)) != 0) 1981 if ((S3I(s)->hs.extensions_seen & (1 << idx)) != 0)
1981 return 0; 1982 goto err;
1982 S3I(s)->hs.extensions_seen |= (1 << idx); 1983 S3I(s)->hs.extensions_seen |= (1 << idx);
1983 1984
1984 ext = tlsext_funcs(tlsext, is_server); 1985 ext = tlsext_funcs(tlsext, is_server);
1985 if (!ext->parse(s, &extension_data, alert)) 1986 if (!ext->parse(s, &extension_data, &alert_desc))
1986 return 0; 1987 goto err;
1987 1988
1988 if (CBS_len(&extension_data) != 0) 1989 if (CBS_len(&extension_data) != 0)
1989 return 0; 1990 goto err;
1990 } 1991 }
1991 1992
1992 return 1; 1993 return 1;
1994
1995 err:
1996 *alert = alert_desc;
1997
1998 return 0;
1993} 1999}
1994 2000
1995static void 2001static void