You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2026/10/17 15:56:08 UTC
(tomcat) 11/16: Fix 32-bit truncation of the WebSocket client I/O timeout
This is an automated email from the ASF dual-hosted git repository.
rmaucher pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit f6e7d6cc0a309b8b187416521b630e9cceed431b
Author: opencode <re...@apache.org>
AuthorDate: Sat Oct 17 12:57:55 2026 +0200
Fix 32-bit truncation of the WebSocket client I/O timeout
The connectToServerRecursive() method read the millisecond value of the
org.apache.tomcat.websocket.IO_TIMEOUT_MS user property with
Long.valueOf(...).intValue(), silently truncating it to 32 bits. A
configured timeout greater than 2^31-1 ms (~24.8 days) was
misinterpreted: a value whose low 32 bits are negative (e.g. 30 days)
became a negative timeout, causing the subsequent Future.get(timeout,
MILLISECONDS) calls for the connection, handshake and request/response
steps to fail immediately, while other large values were silently
shortened to their low 32 bits.
Use longValue(). The value is only ever passed directly to
Future.get(long, TimeUnit.MILLISECONDS), so the restored full long range
introduces no deadline arithmetic issues, and behaviour for values
within the previous int range is unchanged.
---
java/org/apache/tomcat/websocket/WsWebSocketContainer.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/java/org/apache/tomcat/websocket/WsWebSocketContainer.java b/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
index 94dd68da4d..7833309e35 100644
--- a/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
+++ b/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
@@ -278,7 +278,7 @@ public class WsWebSocketContainer implements WebSocketContainer, BackgroundProce
long timeout = Constants.IO_TIMEOUT_MS_DEFAULT;
String timeoutValue = (String) userProperties.get(Constants.IO_TIMEOUT_MS_PROPERTY);
if (timeoutValue != null) {
- timeout = Long.valueOf(timeoutValue).intValue();
+ timeout = Long.valueOf(timeoutValue).longValue();
}
AsynchronousSocketChannel socketChannel;
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org