]> source.dussan.org Git - poi.git/commitdiff
Fix bug #47034 - Reading the name of a NameRecord when the name is > 127
authorNick Burch <nick@apache.org>
Wed, 15 Apr 2009 12:42:53 +0000 (12:42 +0000)
committerNick Burch <nick@apache.org>
Wed, 15 Apr 2009 12:42:53 +0000 (12:42 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@765163 13f79535-47bb-0310-9956-ffa450edef68

src/documentation/content/xdocs/changes.xml
src/documentation/content/xdocs/status.xml
src/java/org/apache/poi/hssf/record/NameRecord.java
src/testcases/org/apache/poi/hssf/data/47034.xls [new file with mode: 0644]
src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java

index e2f50b9ad6e41c551979ba4393389caea6a1b228..577f26407f7b628ca872a5faf0caeb0ff0346228 100644 (file)
@@ -37,6 +37,7 @@
 
                <!-- Don't forget to update status.xml too! -->
         <release version="3.5-beta6" date="2009-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">47034 - Fix reading the name of a NameRecord when the name is very long</action>
            <action dev="POI-DEVELOPERS" type="fix">47001 - Fixed WriteAccessRecord and LinkTable to handle unusual format written by Google Docs</action>
            <action dev="POI-DEVELOPERS" type="fix">46973 - Fixed defined names to behave better when refersToFormula is unset</action>
            <action dev="POI-DEVELOPERS" type="fix">46832 - Allow merged regions with columns greater than 255 or rows bigger than 65536 in XSSF</action>
index 99095f13f2c25f71ad924dc4a0a99a3184ad3e89..40255a08b6346fcee8d2f58e0f63551902019137 100644 (file)
@@ -34,6 +34,7 @@
        <!-- Don't forget to update changes.xml too! -->
     <changes>
         <release version="3.5-beta6" date="2009-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">47034 - Fix reading the name of a NameRecord when the name is very long</action>
            <action dev="POI-DEVELOPERS" type="fix">47001 - Fixed WriteAccessRecord and LinkTable to handle unusual format written by Google Docs</action>
            <action dev="POI-DEVELOPERS" type="fix">46973 - Fixed defined names to behave better when refersToFormula is unset</action>
            <action dev="POI-DEVELOPERS" type="fix">46832 - Allow merged regions with columns greater than 255 or rows bigger than 65536 in XSSF</action>
index 3d48023f4a988b872509bdf9ed80e800b6851137..a93822360607784bd98009d75f5b22a736ead03c 100644 (file)
@@ -416,7 +416,7 @@ public final class NameRecord extends StandardRecord {
                LittleEndianInput in = ris;
                field_1_option_flag                 = in.readShort();
                field_2_keyboard_shortcut           = in.readByte();
-               int field_3_length_name_text        = in.readByte();
+               int field_3_length_name_text        = in.readUByte();
                int field_4_length_name_definition  = in.readShort();
                field_5_externSheetIndex_plus1      = in.readShort();
                field_6_sheetNumber                 = in.readUShort();
diff --git a/src/testcases/org/apache/poi/hssf/data/47034.xls b/src/testcases/org/apache/poi/hssf/data/47034.xls
new file mode 100644 (file)
index 0000000..81c5849
Binary files /dev/null and b/src/testcases/org/apache/poi/hssf/data/47034.xls differ
index d81441c003ebd7fffdec4d06eb32298f3e88f49b..ae650432713d123766077ca43068bb07903c4f51 100644 (file)
@@ -1479,4 +1479,14 @@ public final class TestBugs extends BaseTestBugzillaIssues {
                ));
        }
     }
+    
+    /**
+     * java.lang.NegativeArraySizeException reading long
+     *  non-unicode data for a name record
+     */
+    public void test47034() throws IOException {
+               HSSFWorkbook wb = openSample("47034.xls");
+               assertEquals(893, wb.getNumberOfNames());
+               assertEquals("Matthew\\Matthew11_1\\Matthew2331_1\\Matthew2351_1\\Matthew2361_1___lab", wb.getNameName(300));
+    }
 }