Add checks for invalid row number in RowRecord to find corrupted files earlier

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1678810 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2015-05-11 19:59:52 +00:00
parent 14ca466474
commit 4df1357058
1 changed files with 6 additions and 0 deletions

View File

@ -64,6 +64,9 @@ public final class RowRecord extends StandardRecord {
// bit 15 is unused
public RowRecord(int rowNumber) {
if(rowNumber < 0) {
throw new IllegalArgumentException("Invalid row number " + rowNumber + " specified");
}
field_1_row_number = rowNumber;
field_4_height = (short)0xFF;
field_5_optimize = ( short ) 0;
@ -76,6 +79,9 @@ public final class RowRecord extends StandardRecord {
public RowRecord(RecordInputStream in) {
field_1_row_number = in.readUShort();
if(field_1_row_number < 0) {
throw new IllegalArgumentException("Invalid row number " + field_1_row_number + " found in InputStream");
}
field_2_first_col = in.readShort();
field_3_last_col = in.readShort();
field_4_height = in.readShort();