Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,24 @@ public final void write(byte[] b) throws IOException {

@Override
public final void write(byte[] b, int off, int len) throws IOException {
if (len < 0) {
throw new IndexOutOfBoundsException();
// Sanity check
if (b == null) {
throw new NullPointerException();
}

// Comprehensive bounds checking to prevent integer overflow
if (off < 0 || len < 0 || len > b.length || off > b.length - len) {
throw new ArrayIndexOutOfBoundsException();
}

try {
fileSystemManager.checkQuota(len);
super.write(b, off, len);
} catch (IOException e) {
try {
close();
} catch (IOException ignored) {}
} catch (IOException ignore) {
}
throw e;
}
}
Expand Down