poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fannin...@apache.org
Subject svn commit: r1857594 - in /poi/trunk/src/java/org/apache/poi/poifs/filesystem: POIFSFileSystem.java TempFilePOIFSFileSystem.java
Date Mon, 15 Apr 2019 15:45:59 GMT
Author: fanningpj
Date: Mon Apr 15 15:45:59 2019
New Revision: 1857594

URL: http://svn.apache.org/viewvc?rev=1857594&view=rev
Log:
use ArithmeticUtils for calculations that might overflow

Modified:
    poi/trunk/src/java/org/apache/poi/poifs/filesystem/POIFSFileSystem.java
    poi/trunk/src/java/org/apache/poi/poifs/filesystem/TempFilePOIFSFileSystem.java

Modified: poi/trunk/src/java/org/apache/poi/poifs/filesystem/POIFSFileSystem.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/poifs/filesystem/POIFSFileSystem.java?rev=1857594&r1=1857593&r2=1857594&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/poifs/filesystem/POIFSFileSystem.java (original)
+++ poi/trunk/src/java/org/apache/poi/poifs/filesystem/POIFSFileSystem.java Mon Apr 15 15:45:59
2019
@@ -36,6 +36,7 @@ import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 
+import org.apache.commons.math3.util.ArithmeticUtils;
 import org.apache.poi.EmptyFileException;
 import org.apache.poi.poifs.common.POIFSBigBlockSize;
 import org.apache.poi.poifs.common.POIFSConstants;
@@ -407,7 +408,8 @@ public class POIFSFileSystem extends Blo
         newBAT.setOurBlockIndex(offset);
         // Ensure there's a spot in the file for it
         ByteBuffer buffer = ByteBuffer.allocate(bigBlockSize.getBigBlockSize());
-        int writeTo = (1 + offset) * bigBlockSize.getBigBlockSize(); // Header isn't in BATs
+        // Header isn't in BATs
+        long writeTo = ArithmeticUtils.mulAndCheck((1 + (long)offset), (long)bigBlockSize.getBigBlockSize());
         _data.write(buffer, writeTo);
         // All done
         return newBAT;

Modified: poi/trunk/src/java/org/apache/poi/poifs/filesystem/TempFilePOIFSFileSystem.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/poifs/filesystem/TempFilePOIFSFileSystem.java?rev=1857594&r1=1857593&r2=1857594&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/poifs/filesystem/TempFilePOIFSFileSystem.java (original)
+++ poi/trunk/src/java/org/apache/poi/poifs/filesystem/TempFilePOIFSFileSystem.java Mon Apr
15 15:45:59 2019
@@ -42,7 +42,7 @@ public class TempFilePOIFSFileSystem ext
     }
 
     public void close() throws IOException {
-        if (tempFile != null) tempFile.delete();
+        if (tempFile != null && tempFile.exists()) tempFile.delete();
         super.close();
     }
 



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


Mime
View raw message