8156593: DataOutput.write(byte[],int,int) and its implementations do not specify index out bounds
Reviewed-by: alanb, aturbanov
This commit is contained in:
parent
8480f87044
commit
4999f2cb16
@ -355,6 +355,7 @@ public class BufferedInputStream extends FilterInputStream {
|
||||
* @throws IOException if this input stream has been closed by
|
||||
* invoking its {@link #close()} method,
|
||||
* or an I/O error occurs.
|
||||
* @throws IndexOutOfBoundsException {@inheritDoc}
|
||||
*/
|
||||
public int read(byte[] b, int off, int len) throws IOException {
|
||||
if (lock != null) {
|
||||
|
@ -190,6 +190,7 @@ public class BufferedOutputStream extends FilterOutputStream {
|
||||
* @param off the start offset in the data.
|
||||
* @param len the number of bytes to write.
|
||||
* @throws IOException if an I/O error occurs.
|
||||
* @throws IndexOutOfBoundsException {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void write(byte[] b, int off, int len) throws IOException {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1994, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1994, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -104,6 +104,7 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput {
|
||||
* @param off the start offset in the data.
|
||||
* @param len the number of bytes to write.
|
||||
* @throws IOException if an I/O error occurs.
|
||||
* @throws IndexOutOfBoundsException {@inheritDoc}
|
||||
* @see java.io.FilterOutputStream#out
|
||||
*/
|
||||
public synchronized void write(byte[] b, int off, int len)
|
||||
|
@ -363,6 +363,7 @@ public class FileOutputStream extends OutputStream
|
||||
* @param off {@inheritDoc}
|
||||
* @param len {@inheritDoc}
|
||||
* @throws IOException if an I/O error occurs.
|
||||
* @throws IndexOutOfBoundsException {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void write(byte[] b, int off, int len) throws IOException {
|
||||
|
@ -126,6 +126,7 @@ public class FilterOutputStream extends OutputStream {
|
||||
* @param off {@inheritDoc}
|
||||
* @param len {@inheritDoc}
|
||||
* @throws IOException if an I/O error occurs.
|
||||
* @throws IndexOutOfBoundsException {@inheritDoc}
|
||||
* @see java.io.FilterOutputStream#write(int)
|
||||
*/
|
||||
@Override
|
||||
|
@ -79,6 +79,9 @@ public interface ObjectInput extends DataInput, AutoCloseable {
|
||||
* {@code -1} if there is no more data because the end of
|
||||
* the stream has been reached.
|
||||
* @throws IOException If an I/O error has occurred.
|
||||
* @throws IndexOutOfBoundsException If {@code off} is negative,
|
||||
* {@code len} is negative, or {@code len} is greater than
|
||||
* {@code b.length - off}
|
||||
*/
|
||||
public int read(byte[] b, int off, int len) throws IOException;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -69,6 +69,7 @@ public interface ObjectOutput extends DataOutput, AutoCloseable {
|
||||
* @param off the start offset in the data
|
||||
* @param len the number of bytes that are written
|
||||
* @throws IOException If an I/O error has occurred.
|
||||
* @throws IndexOutOfBoundsException {@inheritDoc}
|
||||
*/
|
||||
public void write(byte[] b, int off, int len) throws IOException;
|
||||
|
||||
|
@ -713,6 +713,7 @@ public class ObjectOutputStream
|
||||
* @param off the start offset in the data
|
||||
* @param len the number of bytes that are written
|
||||
* @throws IOException {@inheritDoc}
|
||||
* @throws IndexOutOfBoundsException {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void write(byte[] buf, int off, int len) throws IOException {
|
||||
|
@ -156,6 +156,9 @@ public abstract class OutputStream implements Closeable, Flushable {
|
||||
* @throws IOException if an I/O error occurs. In particular,
|
||||
* an {@code IOException} is thrown if the output
|
||||
* stream is closed.
|
||||
* @throws IndexOutOfBoundsException If {@code off} is negative,
|
||||
* {@code len} is negative, or {@code len} is greater than
|
||||
* {@code b.length - off}
|
||||
*/
|
||||
public void write(byte[] b, int off, int len) throws IOException {
|
||||
Objects.checkFromIndexSize(off, len, b.length);
|
||||
|
@ -135,6 +135,7 @@ public class PipedOutputStream extends OutputStream {
|
||||
* @throws IOException if the pipe is <a href=#BROKEN> broken</a>,
|
||||
* {@link #connect(java.io.PipedInputStream) unconnected},
|
||||
* closed, or if an I/O error occurs.
|
||||
* @throws IndexOutOfBoundsException {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void write(byte[] b, int off, int len) throws IOException {
|
||||
|
@ -612,6 +612,7 @@ public class PrintStream extends FilterOutputStream
|
||||
* @param buf A byte array
|
||||
* @param off Offset from which to start taking bytes
|
||||
* @param len Number of bytes to write
|
||||
* @throws IndexOutOfBoundsException {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void write(byte[] buf, int off, int len) {
|
||||
|
Loading…
Reference in New Issue
Block a user