poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject svn commit: r550021 - /jakarta/poi/trunk/src/java/org/apache/poi/hpsf/Section.java
Date Sat, 23 Jun 2007 07:44:47 GMT
Author: klute
Date: Sat Jun 23 00:44:47 2007
New Revision: 550021

URL: http://svn.apache.org/viewvc?view=rev&rev=550021
Log:
Consistency check added when reading property set stream. An IllegalPropertyDataException
is thrown if the property set stream is larger than it claims to be.

Modified:
    jakarta/poi/trunk/src/java/org/apache/poi/hpsf/Section.java

Modified: jakarta/poi/trunk/src/java/org/apache/poi/hpsf/Section.java
URL: http://svn.apache.org/viewvc/jakarta/poi/trunk/src/java/org/apache/poi/hpsf/Section.java?view=diff&rev=550021&r1=550020&r2=550021
==============================================================================
--- jakarta/poi/trunk/src/java/org/apache/poi/hpsf/Section.java (original)
+++ jakarta/poi/trunk/src/java/org/apache/poi/hpsf/Section.java Sat Jun 23 00:44:47 2007
@@ -244,6 +244,16 @@
         {
             ple = (PropertyListEntry) propertyList.get(propertyCount - 1);
             ple.length = size - ple.offset;
+            if (ple.length <= 0)
+            {
+                final StringBuffer b = new StringBuffer();
+                b.append("The property set claims to have a size of ");
+                b.append(size);
+                b.append(" bytes. However, it exceeds ");
+                b.append(ple.offset);
+                b.append(" bytes.");
+                throw new IllegalPropertySetDataException(b.toString());
+            }
         }
 
         /* Look for the codepage. */
@@ -322,6 +332,20 @@
                 return 0;
             else
                 return 1;
+        }
+
+        public String toString()
+        {
+            final StringBuffer b = new StringBuffer();
+            b.append(getClass().getName());
+            b.append("[id=");
+            b.append(id);
+            b.append(", offset=");
+            b.append(offset);
+            b.append(", length=");
+            b.append(length);
+            b.append(']');
+            return b.toString();
         }
     }
 



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


Mime
View raw message