poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fannin...@apache.org
Subject svn commit: r1857596 - in /poi/trunk/src: java/org/apache/poi/poifs/filesystem/POIFSFileSystem.java java/org/apache/poi/ss/util/cellwalk/CellWalk.java scratchpad/src/org/apache/poi/hslf/record/MasterTextPropAtom.java
Date Mon, 15 Apr 2019 16:02:53 GMT
Author: fanningpj
Date: Mon Apr 15 16:02:53 2019
New Revision: 1857596

URL: http://svn.apache.org/viewvc?rev=1857596&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/ss/util/cellwalk/CellWalk.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/MasterTextPropAtom.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=1857596&r1=1857595&r2=1857596&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 16:02:53
2019
@@ -113,8 +113,8 @@ public class POIFSFileSystem extends Blo
     protected void createNewDataSource() {
         // Data needs to initially hold just the header block,
         //  a single bat block, and an empty properties section
-        _data = new ByteArrayBackedDataSource(IOUtils.safelyAllocate(
-                bigBlockSize.getBigBlockSize() * 3, MAX_RECORD_LENGTH));
+        long blockSize = ArithmeticUtils.mulAndCheck((long)bigBlockSize.getBigBlockSize(),
(long)3);
+        _data = new ByteArrayBackedDataSource(IOUtils.safelyAllocate(blockSize, MAX_RECORD_LENGTH));
     }
 
     /**

Modified: poi/trunk/src/java/org/apache/poi/ss/util/cellwalk/CellWalk.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/util/cellwalk/CellWalk.java?rev=1857596&r1=1857595&r2=1857596&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/util/cellwalk/CellWalk.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/util/cellwalk/CellWalk.java Mon Apr 15 16:02:53 2019
@@ -17,6 +17,7 @@
 
 package org.apache.poi.ss.util.cellwalk;
 
+import org.apache.commons.math3.util.ArithmeticUtils;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.ss.usermodel.Row;
@@ -91,9 +92,10 @@ public class CellWalk {
                     continue;
                 }
 
-                ctx.ordinalNumber =
-                        (ctx.rowNumber - firstRow) * width +
-                                (ctx.colNumber - firstColumn + 1);
+                long rowSize = ArithmeticUtils.mulAndCheck(
+                        (long)ArithmeticUtils.subAndCheck(ctx.rowNumber, firstRow), (long)width);
+
+                ctx.ordinalNumber = ArithmeticUtils.addAndCheck(rowSize, (ctx.colNumber -
firstColumn + 1));
 
                 handler.onCell(currentCell, ctx);
             }

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/MasterTextPropAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/MasterTextPropAtom.java?rev=1857596&r1=1857595&r2=1857596&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/MasterTextPropAtom.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/MasterTextPropAtom.java Mon Apr
15 16:02:53 2019
@@ -23,6 +23,7 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
+import org.apache.commons.math3.util.ArithmeticUtils;
 import org.apache.poi.hslf.model.textproperties.IndentProp;
 import org.apache.poi.util.IOUtils;
 import org.apache.poi.util.LittleEndian;
@@ -113,7 +114,8 @@ public final class MasterTextPropAtom ex
      */
     private void write() {
         int pos = 0;
-        _data = IOUtils.safelyAllocate(indents.size()*6, MAX_RECORD_LENGTH);
+        long newSize = ArithmeticUtils.mulAndCheck((long)indents.size(), (long)6);
+        _data = IOUtils.safelyAllocate(newSize, MAX_RECORD_LENGTH);
         for (IndentProp prop : indents) {
             LittleEndian.putInt(_data, pos, prop.getCharactersCovered());
             LittleEndian.putShort(_data, pos+4, (short)prop.getIndentLevel());



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


Mime
View raw message