This is an automated email from the ASF dual-hosted git repository.

markt-asf pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/9.0.x by this push:
     new 8f05334c85 Follow-on to "Send the server shutdown command as UTF-8 ..."
8f05334c85 is described below

commit 8f05334c854e3a98a24d3bf50f9ddc49bfd463db
Author: Mark Thomas <[email protected]>
AuthorDate: Mon Oct 19 20:18:16 2026 +0100

    Follow-on to "Send the server shutdown command as UTF-8 ..."
    
    Count bytes not characters since UTF-8 is multi-byte
---
 java/org/apache/catalina/core/StandardServer.java | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/catalina/core/StandardServer.java 
b/java/org/apache/catalina/core/StandardServer.java
index 6f7a1a8de9..c991127306 100644
--- a/java/org/apache/catalina/core/StandardServer.java
+++ b/java/org/apache/catalina/core/StandardServer.java
@@ -584,9 +584,16 @@ public final class StandardServer extends 
LifecycleMBeanBase implements Server {
                         break;
                     }
 
-                    // Read a set of characters from the socket
+                    // Read a set of bytes from the socket
                     int expected = 1024; // Cut off to avoid DoS attack
-                    while (expected < shutdown.length()) {
+                    int shutdownLength;
+                    try {
+                        shutdownLength = shutdown.getBytes("UTF-8").length;
+                    } catch (UnsupportedEncodingException e) {
+                        // Impossible. All JREs are required to support UTF-8.
+                        shutdownLength = shutdown.length();
+                    }
+                    while (expected < shutdownLength) {
                         if (random == null) {
                             random = new Random();
                         }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to