Skip to content

Commit 55c1430

Browse files
committed
IO-307 ReaderInputStream#read(byte[] b, int off, int len) should check for valid parameters
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/io/trunk@1300443 13f79535-47bb-0310-9956-ffa450edef68
1 parent caa0578 commit 55c1430

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

src/changes/changes.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ The <action> type attribute can be add,update,fix,remove.
4040

4141
<body>
4242
<release version="2.2" date="TBA">
43+
<action issue="IO-307" dev="sebb" type="fix">
44+
ReaderInputStream#read(byte[] b, int off, int len) should check for valid parameters
45+
</action>
4346
<action issue="IO-287" dev="bayard" type="add" due-to="Ron Kuris, Gary Gregory">
4447
Use terabyte (TB) , petabyte (PB) and exabyte (EB) in FileUtils.byteCountToDisplaySize(long size)
4548
</action>

src/main/java/org/apache/commons/io/input/ReaderInputStream.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,13 @@ private void fillBuffer() throws IOException {
220220
*/
221221
@Override
222222
public int read(byte[] b, int off, int len) throws IOException {
223+
if (b == null) {
224+
throw new NullPointerException("Byte array must not be null");
225+
}
226+
if (len < 0 || off < 0 || (off + len) > b.length) {
227+
throw new IndexOutOfBoundsException("Array Size=" + b.length +
228+
", offset=" + off + ", length=" + len);
229+
}
223230
int read = 0;
224231
if (len == 0) {
225232
return 0; // Always return 0 if len == 0

0 commit comments

Comments
 (0)