poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r1229963 - in /poi/trunk/src: documentation/content/xdocs/status.xml java/org/apache/poi/poifs/property/NPropertyTable.java
Date Wed, 11 Jan 2012 11:46:41 GMT
Author: nick
Date: Wed Jan 11 11:46:41 2012
New Revision: 1229963

URL: http://svn.apache.org/viewvc?rev=1229963&view=rev
Log:
Fix bug #52446 - Handle files which have been truncated by a few bytes in NPropertyTable

Modified:
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/java/org/apache/poi/poifs/property/NPropertyTable.java

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=1229963&r1=1229962&r2=1229963&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Wed Jan 11 11:46:41 2012
@@ -34,6 +34,7 @@
 
     <changes>
         <release version="3.8-beta6" date="2012-??-??">
+           <action dev="poi-developers" type="fix">52446 - Handle files which have
been truncated by a few bytes in NPropertyTable</action>
            <action dev="poi-developers" type="fix">52438 - Update CellDateFormatter
to handle times without seconds</action>
            <action dev="poi-developers" type="add">52389 - Support ?/? as well as #/#
fractions, and tighten DataFormatter rules for fraction matching</action>
            <action dev="poi-developers" type="add">52200 - Updated XWPF table example
code </action>

Modified: poi/trunk/src/java/org/apache/poi/poifs/property/NPropertyTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/poifs/property/NPropertyTable.java?rev=1229963&r1=1229962&r2=1229963&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/poifs/property/NPropertyTable.java (original)
+++ poi/trunk/src/java/org/apache/poi/poifs/property/NPropertyTable.java Wed Jan 11 11:46:41
2012
@@ -29,6 +29,8 @@ import org.apache.poi.poifs.common.POIFS
 import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
 import org.apache.poi.poifs.filesystem.NPOIFSStream;
 import org.apache.poi.poifs.storage.HeaderBlock;
+import org.apache.poi.util.POILogFactory;
+import org.apache.poi.util.POILogger;
 
 /**
  * This class embodies the Property Table for a {@link NPOIFSFileSystem}; 
@@ -36,6 +38,8 @@ import org.apache.poi.poifs.storage.Head
  * filesystem.
  */
 public final class NPropertyTable extends PropertyTableBase {
+    private static final POILogger _logger =
+       POILogFactory.getLogger(NPropertyTable.class);
     private POIFSBigBlockSize _bigBigBlockSize;
 
     public NPropertyTable(HeaderBlock headerBlock)
@@ -90,7 +94,18 @@ public final class NPropertyTable extend
              data = bb.array();
           } else {
              data = new byte[bigBlockSize.getBigBlockSize()];
-             bb.get(data, 0, data.length);
+             
+             int toRead = data.length;
+             if (bb.remaining() < bigBlockSize.getBigBlockSize()) {
+                // Looks to be a truncated block
+                // This isn't allowed, but some third party created files
+                //  sometimes do this, and we can normally read anyway
+                _logger.log(POILogger.WARN, "Short Property Block, ", bb.remaining(),
+                            " bytes instead of the expected " + bigBlockSize.getBigBlockSize());
+                toRead = bb.remaining();
+             }
+             
+             bb.get(data, 0, toRead);
           }
           
           PropertyFactory.convertToProperties(data, properties);



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


Mime
View raw message