You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by Joe Gallo <jo...@gmail.com> on 2011/10/07 14:09:04 UTC

VariantSupport confuses bytes and chars for LPWSTR

A coworker and I ran into some ArrayIndexOutOfBoundsExceptions while processing
ppt files using POI (by way of Tika), and tracked the problem down to some of
the code in VariantSupport.  

Joe

Index: src/java/org/apache/poi/hpsf/VariantSupport.java
===================================================================
--- src/java/org/apache/poi/hpsf/VariantSupport.java	(revision 1179871)
+++ src/java/org/apache/poi/hpsf/VariantSupport.java	(working copy)
@@ -252,10 +252,10 @@
                  */
                 final int first = o1 + LittleEndian.INT_SIZE;
                 long last = first + LittleEndian.getUInt(src, o1) - 1;
-                long l = last - first;
+                long l = last - first + 1; // bytes
                 o1 += LittleEndian.INT_SIZE;
                 StringBuffer b = new StringBuffer((int) (last - first));
-                for (int i = 0; i <= l; i++)
+                for (int i = 0; i < l/2; i++) // characters
                 {
                     final int i1 = o1 + (i * 2);
                     final int i2 = i1 + 1;



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


VariantSupport confuses bytes and chars for LPWSTR

Posted by Joe Gallo <jo...@gmail.com>.
Nick Burch <nick.burch <at> alfresco.com> writes:

> Any chance you could open a new bug in bugzilla, and post both the patch 
> and a problem file there? We can then use the problem file as part of a 
> unit test to verify the fix works, as well as to ensure it doesn't get 
> broken going forward

Created -- please correct any errors I've made while filling it out.

https://issues.apache.org/bugzilla/show_bug.cgi?id=51992

I can't attach the files we used, but I'll see if I can create a new one that
demonstrates the problem.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


Re: VariantSupport confuses bytes and chars for LPWSTR

Posted by Nick Burch <ni...@alfresco.com>.
On Fri, 7 Oct 2011, Joe Gallo wrote:
> A coworker and I ran into some ArrayIndexOutOfBoundsExceptions while 
> processing ppt files using POI (by way of Tika), and tracked the problem 
> down to some of the code in VariantSupport.

Any chance you could open a new bug in bugzilla, and post both the patch 
and a problem file there? We can then use the problem file as part of a 
unit test to verify the fix works, as well as to ensure it doesn't get 
broken going forward

Cheers
Nick

> Joe
>
> Index: src/java/org/apache/poi/hpsf/VariantSupport.java
> ===================================================================
> --- src/java/org/apache/poi/hpsf/VariantSupport.java	(revision 1179871)
> +++ src/java/org/apache/poi/hpsf/VariantSupport.java	(working copy)
> @@ -252,10 +252,10 @@
>                  */
>                 final int first = o1 + LittleEndian.INT_SIZE;
>                 long last = first + LittleEndian.getUInt(src, o1) - 1;
> -                long l = last - first;
> +                long l = last - first + 1; // bytes
>                 o1 += LittleEndian.INT_SIZE;
>                 StringBuffer b = new StringBuffer((int) (last - first));
> -                for (int i = 0; i <= l; i++)
> +                for (int i = 0; i < l/2; i++) // characters
>                 {
>                     final int i1 = o1 + (i * 2);
>                     final int i2 = i1 + 1;
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
> For additional commands, e-mail: dev-help@poi.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org