This is an automated email from the ASF dual-hosted git repository.
markt-asf pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push:
new 540f6eefe6 Review "Fix zero-length read handling in the input
stream..."
540f6eefe6 is described below
commit 540f6eefe6dd3a10d3e1208da5e43674df99e3f9
Author: Mark Thomas <[email protected]>
AuthorDate: Mon Nov 2 12:12:50 2026 +0000
Review "Fix zero-length read handling in the input stream..."
Negative lengths are invalid
Expand checks on provided arguments for read
---
.../apache/coyote/http11/upgrade/UpgradeServletInputStream.java | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git
a/java/org/apache/coyote/http11/upgrade/UpgradeServletInputStream.java
b/java/org/apache/coyote/http11/upgrade/UpgradeServletInputStream.java
index ea7e78806b..b5f16dfeaa 100644
--- a/java/org/apache/coyote/http11/upgrade/UpgradeServletInputStream.java
+++ b/java/org/apache/coyote/http11/upgrade/UpgradeServletInputStream.java
@@ -17,6 +17,7 @@
package org.apache.coyote.http11.upgrade;
import java.io.IOException;
+import java.util.Objects;
import java.util.concurrent.atomic.AtomicBoolean;
import jakarta.servlet.ReadListener;
@@ -176,10 +177,12 @@ public class UpgradeServletInputStream extends
ServletInputStream {
@Override
public final int readLine(byte[] b, int off, int len) throws IOException {
preReadChecks();
+ Objects.checkFromIndexSize(off, len, b.length);
- if (len <= 0) {
+ if (len == 0) {
return 0;
}
+
int count = 0, c;
while ((c = readInternal()) != -1) {
@@ -201,9 +204,10 @@ public class UpgradeServletInputStream extends
ServletInputStream {
@Override
public final int read(byte[] b, int off, int len) throws IOException {
preReadChecks();
+ Objects.checkFromIndexSize(off, len, b.length);
// The input must not be touched if the caller requested zero bytes.
- if (len <= 0) {
+ if (len == 0) {
return 0;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]