summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjsing <>2017-08-29 17:24:12 +0000
committerjsing <>2017-08-29 17:24:12 +0000
commit84113b351970b142c1aa31f17c83e5487656f281 (patch)
tree02c389737bba0e49320052de1d4d4b0cf5f745b8
parent56a18d470b7bb2ae94290cc6db87a0ee1315d0a9 (diff)
downloadopenbsd-84113b351970b142c1aa31f17c83e5487656f281.tar.gz
openbsd-84113b351970b142c1aa31f17c83e5487656f281.tar.bz2
openbsd-84113b351970b142c1aa31f17c83e5487656f281.zip
Actually parse the ALPN extension in a client hello, even if no ALPN
callback has been installed. This ensures that the ALPN extension is valid and avoids leaving unprocessed extension data, which leads to a decode error. Found the hard way by jsg@
-rw-r--r--src/lib/libssl/ssl_tlsext.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/lib/libssl/ssl_tlsext.c b/src/lib/libssl/ssl_tlsext.c
index 2438b90d04..6b60ccd27f 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.12 2017/08/27 02:58:04 doug Exp $ */ 1/* $OpenBSD: ssl_tlsext.c,v 1.13 2017/08/29 17:24:12 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2016, 2017 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2016, 2017 Joel Sing <jsing@openbsd.org>
4 * Copyright (c) 2017 Doug Hogan <doug@openbsd.org> 4 * Copyright (c) 2017 Doug Hogan <doug@openbsd.org>
@@ -61,9 +61,6 @@ tlsext_alpn_clienthello_parse(SSL *s, CBS *cbs, int *alert)
61 unsigned char selected_len; 61 unsigned char selected_len;
62 int r; 62 int r;
63 63
64 if (s->ctx->internal->alpn_select_cb == NULL)
65 return 1;
66
67 if (!CBS_get_u16_length_prefixed(cbs, &alpn)) 64 if (!CBS_get_u16_length_prefixed(cbs, &alpn))
68 goto err; 65 goto err;
69 if (CBS_len(&alpn) < 2) 66 if (CBS_len(&alpn) < 2)
@@ -81,6 +78,9 @@ tlsext_alpn_clienthello_parse(SSL *s, CBS *cbs, int *alert)
81 goto err; 78 goto err;
82 } 79 }
83 80
81 if (s->ctx->internal->alpn_select_cb == NULL)
82 return 1;
83
84 r = s->ctx->internal->alpn_select_cb(s, &selected, &selected_len, 84 r = s->ctx->internal->alpn_select_cb(s, &selected, &selected_len,
85 CBS_data(&alpn), CBS_len(&alpn), 85 CBS_data(&alpn), CBS_len(&alpn),
86 s->ctx->internal->alpn_select_cb_arg); 86 s->ctx->internal->alpn_select_cb_arg);