You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2017/05/01 20:06:39 UTC

[Bug 61059] New: [PATCH] Fix incorrect use of short when unsigned short was required in NamePtg

https://bz.apache.org/bugzilla/show_bug.cgi?id=61059

            Bug ID: 61059
           Summary: [PATCH] Fix incorrect use of short when unsigned short
                    was required in NamePtg
           Product: POI
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: blocker
          Priority: P2
         Component: SS Common
          Assignee: dev@poi.apache.org
          Reporter: admin.apache@moparisthebest.com
  Target Milestone: ---

Created attachment 34967
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=34967&action=edit
0001-Fix-incorrect-use-of-short-when-unsigned-short-was-r.patch

A large spreadsheet (my guess is > 32k rows) crashes in the
FormulaEvaluator.evaluate(Cell) function with this error:


java.lang.ArrayIndexOutOfBoundsException: -32760
        at java.util.ArrayList.elementData(ArrayList.java:418) ~[na:1.8.0_121]
        at java.util.ArrayList.get(ArrayList.java:431) ~[na:1.8.0_121]
        at
org.apache.poi.hssf.model.LinkTable.getNameRecord(LinkTable.java:321)
~[poi-3.16.jar:3.16]
        at
org.apache.poi.hssf.model.InternalWorkbook.getNameRecord(InternalWorkbook.java:1660)
~[poi-3.16.jar:3.16]
        at
org.apache.poi.hssf.usermodel.HSSFEvaluationWorkbook.getName(HSSFEvaluationWorkbook.java:220)
~[poi-3.16.jar:3.16]
        at
org.apache.poi.ss.formula.WorkbookEvaluator.getEvalForPtg(WorkbookEvaluator.java:616)
~[poi-3.16.jar:3.16]
        at
org.apache.poi.ss.formula.WorkbookEvaluator.evaluateFormula(WorkbookEvaluator.java:525)
~[poi-3.16.jar:3.16]
        at
org.apache.poi.ss.formula.WorkbookEvaluator.evaluateAny(WorkbookEvaluator.java:290)
~[poi-3.16.jar:3.16]
        at
org.apache.poi.ss.formula.WorkbookEvaluator.evaluate(WorkbookEvaluator.java:232)
~[poi-3.16.jar:3.16]
        at
org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator.evaluateFormulaCellValue(HSSFFormulaEvaluator.java:200)
~[poi-3.16.jar:3.16]
        at
org.apache.poi.ss.formula.BaseFormulaEvaluator.evaluate(BaseFormulaEvaluator.java:101)
~[poi-3.16.jar:3.16]

I tracked down the bug in org.apache.poi.ss.formula.ptg.NamePtg line 47:

field_1_label_index = in.readShort();

Changing that to

field_1_label_index = in.readUShort();

Fixes the problem.  I *think* that is the *right* fix, but you guys might know
better.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 61059] [PATCH] Fix incorrect use of short when unsigned short was required in NamePtg

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61059

--- Comment #1 from Javen O'Neal <on...@apache.org> ---
Does this value need to be written out as a ushort as well?

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 61059] [PATCH] Fix incorrect use of short when unsigned short was required in NamePtg

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61059

Javen O'Neal <on...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO

--- Comment #2 from Javen O'Neal <on...@apache.org> ---
Are you able to share the problematic workbook for inclusion in our unit test
suite? Otherwise we could write some unit test code to generate a workbook and
check for this AIOOBE. Are you able to figure out what formula string triggered
this exception? Does your workbook have greater than 32767 names in the
NameManager?

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 61059] [PATCH] Fix incorrect use of short when unsigned short was required in NamePtg

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61059

--- Comment #3 from Javen O'Neal <on...@apache.org> ---
(In reply to Javen O'Neal from comment #1)
> Does this value need to be written out as a ushort as well?

Disregard this question. It looks like the signed/unsigned differentiation is
only made when reading the value. Signed and unsigned shorts have the same
binary representation.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 61059] [PATCH] Fix incorrect use of short when unsigned short was required in NamePtg

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61059

Javen O'Neal <on...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEEDINFO                    |RESOLVED

--- Comment #4 from Javen O'Neal <on...@apache.org> ---
Applied in r1796466 without a unit test.

These changes will be available in POI 3.17 beta 1.

If anyone can provide a supporting document or unit test to make sure this
stays fixed in the future, please reopen this bug and attach the info.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 61059] [PATCH] Fix incorrect use of short when unsigned short was required in NamePtg

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61059

Dominik Stadler <do...@gmx.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |PatchAvailable

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org