This is an automated email from the ASF dual-hosted git repository.
markt-asf pushed a commit to branch 1.3.x
in repository https://gitbox.apache.org/repos/asf/tomcat-native.git
The following commit(s) were added to refs/heads/1.3.x by this push:
new ce019af0d Avoid a potential crash with very long ALPN protocol names
ce019af0d is described below
commit ce019af0db385dfd5bc7c7a759f71602559a0499
Author: Mark Thomas <[email protected]>
AuthorDate: Thu Aug 27 17:23:54 2026 +0100
Avoid a potential crash with very long ALPN protocol names
---
native/include/ssl_private.h | 2 +-
native/src/sslcontext.c | 5 +++--
xdocs/miscellaneous/changelog.xml | 3 +++
3 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/native/include/ssl_private.h b/native/include/ssl_private.h
index f4e04e783..c272a89b7 100644
--- a/native/include/ssl_private.h
+++ b/native/include/ssl_private.h
@@ -219,7 +219,7 @@ extern ENGINE *tcn_ssl_engine;
#endif /* !defined(OPENSSL_NO_TLSEXT) && defined(SSL_set_tlsext_host_name) */
-#define MAX_ALPN_PROTO_SIZE 65535
+#define MAX_ALPN_PROTO_SIZE 255
#define SSL_SELECTOR_FAILURE_CHOOSE_MY_LAST_PROTOCOL 1
typedef struct tcn_ssl_ctxt_t tcn_ssl_ctxt_t;
diff --git a/native/src/sslcontext.c b/native/src/sslcontext.c
index fb4ba8f4b..ff6271534 100644
--- a/native/src/sslcontext.c
+++ b/native/src/sslcontext.c
@@ -1561,8 +1561,9 @@ static int initProtocols(JNIEnv *e, unsigned char
**proto_data, unsigned int *pr
// Find start of buffer
unsigned char *p_data_start = p_data - (p_data_len - (1 +
proto_chars_len));
unsigned char *p_data_tmp;
- // double size
- p_data_size <<= 1;
+ // double size until sufficient space is available
+ while (p_data_len > p_data_size)
+ p_data_size <<= 1;
p_data_tmp = realloc(p_data_start, p_data_size);
if (p_data_tmp == NULL) {
// Not enough memory? Free the original buffer.
diff --git a/xdocs/miscellaneous/changelog.xml
b/xdocs/miscellaneous/changelog.xml
index 193c7240d..1bf198aed 100644
--- a/xdocs/miscellaneous/changelog.xml
+++ b/xdocs/miscellaneous/changelog.xml
@@ -63,6 +63,9 @@
<fix>
Fix a potential crash when configuring raw certificates. (markt)
</fix>
+ <fix>
+ Avoid a potential crash with very long ALPN protocol names. (markt)
+ </fix>
</changelog>
</section>
<section name="1.3.8" rtext="2026-06-15">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]