From 4df135705847177e67a73bf5b62045e813a1a041 Mon Sep 17 00:00:00 2001 From: Dominik Stadler Date: Mon, 11 May 2015 19:59:52 +0000 Subject: [PATCH] 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 --- src/java/org/apache/poi/hssf/record/RowRecord.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/java/org/apache/poi/hssf/record/RowRecord.java b/src/java/org/apache/poi/hssf/record/RowRecord.java index 75d3f99b13..7a9026dc54 100644 --- a/src/java/org/apache/poi/hssf/record/RowRecord.java +++ b/src/java/org/apache/poi/hssf/record/RowRecord.java @@ -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(); -- 2.39.5