This is an automated email from the ASF dual-hosted git repository.
markt-asf pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/10.1.x by this push:
new 6656700bea Review "Fix zero-length read handling in the input
stream..."
6656700bea is described below
commit 6656700bea44fcc1df15a6a82f30855a6f4f444e
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 d107e0527f..700309fc28 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]